在Go Web应用程序中,我有一个嵌入式FS,其中包含静态文件和模板文件.
索引函数func index(w http.ResponseWriter, r *http.Request)
正在解析和执行模板.
我如何才能在/
条道路上为两者服务?
GET /
will serve index
GET/{anythingelse}
will be served from FS
//go:embed assets
var staticFiles embed.FS
var staticFS = fs.FS(staticFiles)
htmlContent, _ := fs.Sub(staticFS, "assets")
fs := http.FileServer(http.FS(htmlContent))
mux := http.NewServeMux()
mux.Handle("GET /", fs)
mux.HandleFunc("GET /", index)
julienschmidt/httprouter
有router.NotFound.我怎样才能做到同样的事情?