Separate router initialization into it's own function

This commit is contained in:
Las Zenow 2013-04-16 13:39:22 +02:00
parent 8ddb7a0f89
commit c4373c8773

View file

@ -121,7 +121,11 @@ func main() {
db = initDB()
defer db.Close()
/* set up web handlers */
setUpRouter()
panic(http.ListenAndServe(":"+PORT, nil))
}
func setUpRouter() {
r := mux.NewRouter()
r.HandleFunc("/", indexHandler)
r.HandleFunc("/book/{id:[0-9a-fA-F]+}", bookHandler)
@ -149,5 +153,4 @@ func main() {
h = http.FileServer(http.Dir(JS_PATH))
r.Handle("/js/{js}", http.StripPrefix("/js/", h))
http.Handle("/", r)
panic(http.ListenAndServe(":"+PORT, nil))
}