コード例 #1
0
ファイル: server.go プロジェクト: hc5duke/bones
func main() {
	sqlrepositories.Connect(config.DatabaseConnectionString())
	defer sqlrepositories.Cleanup()

	sessions.Enable()

	setupDependencies()

	http.Handle("/assets/", http.StripPrefix("/assets/", http.FileServer(http.Dir("./assets"))))

	http.HandleFunc("/favicon.ico", func(req http.ResponseWriter, res *http.Request) {
		http.ServeFile(req, res, "./assets/images/favicon.png")
	})

	http.HandleFunc("/robots.txt", func(req http.ResponseWriter, res *http.Request) {
		http.ServeFile(req, res, "./assets/robots.txt")
	})

	setupRouting()

	http.Handle("/", r)

	port := portFromEnvOrDefault()
	log.Println("Starting server on port", port)
	log.Fatal(http.ListenAndServe(":"+port, nil))
}
コード例 #2
0
ファイル: server.go プロジェクト: patrickToca/bones
func main() {
	repositories.Connect(config.DatabaseConnectionString())
	defer repositories.Cleanup()

	repositories.EnableSessions()

	setupDependencies()

	setupRouting()

	http.Handle("/", r)
	http.Handle("/assets/", http.StripPrefix("/assets/", http.FileServer(http.Dir("./assets"))))

	port := portFromEnvOrDefault()
	log.Println("Starting server on port", port)
	log.Fatal(http.ListenAndServe(":"+port, nil))
}