parent
0ce132eb8f
commit
0327f30e3c
@ -188,7 +188,7 @@ func (r *registryRouter) store(services []*registry.Service) {
|
|||||||
for _, p := range ep.Endpoint.Path {
|
for _, p := range ep.Endpoint.Path {
|
||||||
var pcreok bool
|
var pcreok bool
|
||||||
|
|
||||||
if p[0] == '^' && p[len(p)-1] != '$' {
|
if p[0] == '^' && p[len(p)-1] == '$' {
|
||||||
pcrereg, err := regexp.CompilePOSIX(p)
|
pcrereg, err := regexp.CompilePOSIX(p)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
cep.pcreregs = append(cep.pcreregs, pcrereg)
|
cep.pcreregs = append(cep.pcreregs, pcrereg)
|
||||||
|
34
api/router/registry/registry_test.go
Normal file
34
api/router/registry/registry_test.go
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
package registry
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/micro/go-micro/v2/registry"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestStoreRegex(t *testing.T) {
|
||||||
|
router := newRouter()
|
||||||
|
router.store([]*registry.Service{
|
||||||
|
{
|
||||||
|
Name: "Foobar",
|
||||||
|
Version: "latest",
|
||||||
|
Endpoints: []*registry.Endpoint{
|
||||||
|
{
|
||||||
|
Name: "foo",
|
||||||
|
Metadata: map[string]string{
|
||||||
|
"endpoint": "FooEndpoint",
|
||||||
|
"description": "Some description",
|
||||||
|
"method": "POST",
|
||||||
|
"path": "^/foo/$",
|
||||||
|
"handler": "rpc",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Metadata: map[string]string{},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
assert.Len(t, router.ceps["Foobar.foo"].pcreregs, 1)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user