diff --git a/middleware/denco/router.go b/middleware/denco/router.go index ecacc31f..5d2691ec 100644 --- a/middleware/denco/router.go +++ b/middleware/denco/router.go @@ -20,6 +20,9 @@ const ( // SeparatorCharacter separates path segments. SeparatorCharacter = '/' + // PathParamCharacter indicates a RESTCONF path param + PathParamCharacter = '=' + // MaxSize is max size of records and internal slice. MaxSize = (1 << 22) - 1 ) @@ -426,8 +429,9 @@ func makeRecords(srcs []Record) (statics, params []*record) { termChar := string(TerminationCharacter) paramPrefix := string(SeparatorCharacter) + string(ParamCharacter) wildcardPrefix := string(SeparatorCharacter) + string(WildcardCharacter) + restconfPrefix := string(PathParamCharacter) + string(ParamCharacter) for _, r := range srcs { - if strings.Contains(r.Key, paramPrefix) || strings.Contains(r.Key, wildcardPrefix) { + if strings.Contains(r.Key, paramPrefix) || strings.Contains(r.Key, wildcardPrefix) ||strings.Contains(r.Key, restconfPrefix){ r.Key += termChar params = append(params, &record{Record: r}) } else { diff --git a/middleware/denco/router_test.go b/middleware/denco/router_test.go index 7e4b7849..81eb55c1 100644 --- a/middleware/denco/router_test.go +++ b/middleware/denco/router_test.go @@ -26,6 +26,7 @@ func routes() []denco.Record { {"/:year/:month/:day", "testroute8"}, {"/user/:id", "testroute9"}, {"/a/to/b/:param/*routepath", "testroute10"}, + {"/path/with/key=:value", "testroute14"}, } } @@ -211,6 +212,7 @@ func TestRouter_Lookup(t *testing.T) { {"/user/777", "testroute9", []denco.Param{{"id", "777"}}, true}, {"/a/to/b/p1/some/wildcard/params", "testroute10", []denco.Param{{"param", "p1"}, {"routepath", "some/wildcard/params"}}, true}, {"/missing", nil, nil, false}, + {"/path/with/key=value", "testroute14", []denco.Param{{"value", "value"}}, true}, } runLookupTest(t, routes(), testcases)