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 am trying to use *path catch-all syntax to match both http://localhost:8080/example/some/path and http://localhost:8080/example/. I expect that catch-all syntax will handle latter with empty "path" param, but it doesn't. I got 404.
package main
import (
"github.com/dimfeld/httptreemux"
"net/http"
)
func main() {
router := httptreemux.NewContextMux()
h := func(w http.ResponseWriter, r *http.Request) {
params := httptreemux.ContextParams(r.Context())
w.Write([]byte(params["path"]))
}
router.GET("/example/*path", h)
http.ListenAndServe(":8080", router)
}
I am trying to use
*path
catch-all syntax to match bothhttp://localhost:8080/example/some/path
andhttp://localhost:8080/example/
. I expect that catch-all syntax will handle latter with empty "path" param, but it doesn't. I got 404.I can workaround it with adding one more handler:
But I didn't have to do it with https://github.com/julienschmidt/httprouter
If this is not an issue by design, I would at least mention this in documentation :)
The text was updated successfully, but these errors were encountered: