gorilla/mux如何实现静态资源啊 css js

hellsam · · 2309 次点击
更多评论
``` func main() { var dir="static" r := mux.NewRouter() // This will serve files under http://localhost:8000/static/<filename> r.PathPrefix("/static/").Handler(http.StripPrefix("/static/", http.FileServer(http.Dir(dir)))) srv := &http.Server{ Handler: r, Addr: "127.0.0.1:8000", } log.Fatal(srv.ListenAndServe()) } ``` http://localhost:8000/static/js/jquery.js
#1