util/router: sync from github

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2021-08-03 00:19:53 +03:00
parent f2e6b7540c
commit 46d4461f6d
4 changed files with 7 additions and 20 deletions

View File

@ -25,7 +25,7 @@ func TestCompile(t *testing.T) {
segs: []segment{
literal(eof),
},
ops: []int{int(utilities.OpLitPush), 0},
ops: []int{int(OpLitPush), 0},
pool: []string{""},
},
{

View File

@ -3,11 +3,8 @@ package router
// download from https://raw.githubusercontent.com/grpc-ecosystem/grpc-gateway/master/protoc-gen-grpc-gateway/httprule/parse.go
import (
"context"
"fmt"
"strings"
"github.com/unistack-org/micro/v3/logger"
)
// InvalidTemplateError indicates that the path template is not valid.

View File

@ -4,7 +4,6 @@ package router
import (
"context"
"flag"
"fmt"
"reflect"
"testing"
@ -135,10 +134,6 @@ func TestTokenize(t *testing.T) {
}
func TestParseSegments(t *testing.T) {
err := flag.Set("v", "3")
if err != nil {
t.Fatalf("failed to set flag: %v", err)
}
for _, spec := range []struct {
tokens []string
want []segment
@ -298,10 +293,6 @@ func TestParseSegments(t *testing.T) {
}
func TestParseSegmentsWithErrors(t *testing.T) {
err := flag.Set("v", "3")
if err != nil {
t.Fatalf("failed to set flag: %v", err)
}
for _, spec := range []struct {
tokens []string
}{

View File

@ -143,13 +143,12 @@ func NewPattern(version int, ops []int, pool []string, verb string) (Pattern, er
typedOps = append(typedOps, op)
}
return Pattern{
ops: typedOps,
pool: pool,
vars: vars,
stacksize: maxstack,
tailLen: tailLen,
verb: verb,
assumeColonVerb: options.assumeColonVerb,
ops: typedOps,
pool: pool,
vars: vars,
stacksize: maxstack,
tailLen: tailLen,
verb: verb,
}, nil
}