I'm using httprouter for parsing some parameters from the path in api calls:
router := httprouter.New()
router.GET("/api/:param1/:param2", apiHandler)
And wanted to add some files to the root (/
) to serve. It's just index.html
, script.js
and style.css
. All in a local directory called static
router.ServeFiles("/*filepath", http.Dir("static"))
So that I can go with the browser to localhost:8080/
and it will serve index.html
and the js
from the browser will call the /api/:param1/:param2
But this path conflicts with the /api
path.
panic: wildcard route '*filepath' conflicts with existing children in path '/*filepath'