yuokada / gohcs

MIT License
0 stars 0 forks source link

FR: Entrypoint is dynamic. mulitiple Entrypoint. #12

Closed yuokada closed 7 years ago

yuokada commented 7 years ago

https://github.com/yuokada/gohcs/blob/master/src/server.go#L102

yuokada commented 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")))
yuokada commented 7 years ago
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