我设置了以下路由:
func (app *application) routes() *mux.Router {
r := mux.NewRouter()
fs := http.FileServer(http.Dir("./ui/static/"))
r.PathPrefix("/ui/static/").Handler(http.StripPrefix("/ui/static/", fs))
authRequired := r.PathPrefix("/").Subrouter()
authRequired.HandleFunc("/foo", app.foo).Methods("POST") // <- this one works fine
authRequired.HandleFunc("/bar/{id:[0-9]+}", app.bar) // <- this does not
return r
}
当我调用URL http://server/foo
时,一切都很好。与例如http://server/bar/1
网站已交付,但我收到类似[]的错误消息
The resource "http://server/bar/ui/static/css/style.css" has been blocked due to mime type mismatch
/bar
中的http://server/bar/ui/static/...
不应该存在。我该如何解决?
我设置了以下路由:func(应用程序*应用程序)route()* mux.Router {r:= mux.NewRouter()fs:= http.FileServer(http.Dir(“ ./ ui / static / “))r.PathPrefix(” / ui / static /“)....
The resource "http://server/bar/ui/static/css/style.css" has been blocked due to mime type mismatch