You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I really hope the ServeMux enhancements end up in the stdlib! And I apologize if this feedback is too early ... but while attempting to add a test using muxpatterns (I'm really hoping this gets into the stdlib!), I noticed a couple of issues.
There seems to be a routing bug where HandleFunc("GET /api/widgets/{slug}", h) matches the path /api/widgets/ and provides "/" as the path value for slug. I would have expected that to not match at all (slug needs to be 1 or more characters), as all the other routing libraries do.
The other issue (and maybe this just hasn't been programmed yet) is that muxpatterns doesn't yet seem to return 405 MethodNotAllowed errors as expected. It definitely seems in the spirit of the HTTP status codes to return 405, and your comment here seems to suggest that the enhanced http.ServeMux will too. Should be straight-forward to reproduce, but run go test on my test code if you can't.
$ curl -X POST http://localhost:8080/api/widgets/foo # expected 405
404 page not found
The text was updated successfully, but these errors were encountered:
I really hope the
ServeMux
enhancements end up in the stdlib! And I apologize if this feedback is too early ... but while attempting to add a test usingmuxpatterns
(I'm really hoping this gets into the stdlib!), I noticed a couple of issues.HandleFunc("GET /api/widgets/{slug}", h)
matches the path/api/widgets/
and provides"/"
as the path value forslug
. I would have expected that to not match at all (slug needs to be 1 or more characters), as all the other routing libraries do.Here's a program that reproduces this:
If you run that and then
curl
that URL, you get this:muxpatterns
doesn't yet seem to return 405 MethodNotAllowed errors as expected. It definitely seems in the spirit of the HTTP status codes to return 405, and your comment here seems to suggest that the enhancedhttp.ServeMux
will too. Should be straight-forward to reproduce, but rungo test
on my test code if you can't.The text was updated successfully, but these errors were encountered: