goweb icon indicating copy to clipboard operation
goweb copied to clipboard

trailling slash with url /hello/ should return not found as /hello/xx/

Open tablecell opened this issue 4 years ago • 3 comments

http://localhost:8080/hello/xx/ return {"message":"Page Not Found"}

but http://localhost:8080/hello/ return {"hello":""}

tablecell avatar Aug 20 '21 05:08 tablecell

It looks like your two examples are the same? Is there a typo? Or, can you explain the problem a bit more?

twharmon avatar Aug 20 '21 16:08 twharmon

It looks like your two examples are the same? Is there a type? Or, can you explain the problem a bit more?

issue updated

http://localhost:8080/hello/xxx/ return {"message":"Page Not Found"}

but http://localhost:8080/hello/ return {"hello":""}

expect http://localhost:8080/hello/xxx match app.GET("/hello/{name}" http://localhost:8080/hello/ or http://localhost:8080/hello/xxx/ return 404

tablecell avatar Aug 20 '21 16:08 tablecell

It looks like trailing slashes aren't handled the way you are expecting them.

app.GET("/hello/{name}", handler) will match /hello/ with name === "". app.GET("/hello/{name}", handler) will not match /hello/Bob/ and 404 will be returned.

I welcome a PR that allows the trailing slash config to be customized.

twharmon avatar Oct 14 '21 17:10 twharmon