我正在使用httprouter从 api 调用中的路径解析一些参数:
router := httprouter.New()
router.GET("/api/:param1/:param2", apiHandler)
并想将一些文件添加到根 ( /
) 以提供服务。只是和。index.html
_ 全部在一个名为的本地目录中script.js
style.css
static
router.ServeFiles("/*filepath", http.Dir("static"))
这样我就可以使用浏览器访问localhost:8080/
它,它会服务index.html
并且js
来自浏览器的将调用/api/:param1/:param2
但是这条路径与路径冲突/api
。
panic: wildcard route '*filepath' conflicts with existing children in path '/*filepath'