Closed yuokada closed 7 years ago
see: http://qiita.com/tenntenn/items/7f532cc883c9ba3151a8
// 静的ファイルのハンドリング -> ファイルサーバへ
http.Handle("/", http.FileServer(http.Dir("static")))
// Webサーバの開始
http.Handle("/", http.FileServer(http.Dir("static")))
func main() {
assets := http.StripPrefix("/", http.FileServer(http.Dir("assets/")))
http.Handle("/", assets)
log.Println("Listening at port 3000")
log.Fatal(http.ListenAndServe(":3000", nil))
}
func main() {
r := mux.NewRouter()
r.PathPrefix("/").Handler(http.StripPrefix("/", http.FileServer(http.Dir("assets/"))))
log.Println("Listening at port 3000")
http.ListenAndServe(":3000", r)
}
Serving static files with golang or gorilla mux http://idealogylabs.com/blog/golang/2015/07/24/serving-static-files-with-golang-gorilla-mux.html
https://github.com/yuokada/gohcs/blob/master/src/server.go#L102