changed parameter identifier to brackets over a colon, is more compatable with OpenAPI
This commit is contained in:
parent
f9a712bc33
commit
086c404610
@ -84,9 +84,9 @@ func (r *route) match(ctx context.Context, router *ServeMux, segs []string) (con
|
||||
return nil, false
|
||||
}
|
||||
isParam := false
|
||||
if strings.HasPrefix(seg, ":") {
|
||||
if strings.HasPrefix(seg, "{") {
|
||||
isParam = true
|
||||
seg = strings.TrimPrefix(seg, ":")
|
||||
seg = strings.Trim(seg, "{}")
|
||||
}
|
||||
if !isParam { // verbatim check
|
||||
if strings.HasSuffix(seg, "...") {
|
||||
|
@ -116,11 +116,11 @@ var tests = []struct {
|
||||
},
|
||||
// path params
|
||||
{
|
||||
"/path-param/:id",
|
||||
"/path-param/{id}",
|
||||
"GET", "/path-param/123", true, map[string]string{"id": "123"},
|
||||
},
|
||||
{
|
||||
"/path-params/:era/:group/:member",
|
||||
"/path-params/{era}/{group}/{member}",
|
||||
"GET", "/path-params/60s/beatles/lennon", true, map[string]string{
|
||||
"era": "60s",
|
||||
"group": "beatles",
|
||||
@ -128,7 +128,7 @@ var tests = []struct {
|
||||
},
|
||||
},
|
||||
{
|
||||
"/path-params-prefix/:era/:group/:member/",
|
||||
"/path-params-prefix/{era}/{group}/{member}/",
|
||||
"GET", "/path-params-prefix/60s/beatles/lennon/yoko", true, map[string]string{
|
||||
"era": "60s",
|
||||
"group": "beatles",
|
||||
|
Loading…
Reference in New Issue
Block a user