From c4373c8773a48e888ad7a1da9b94091573bc90ee Mon Sep 17 00:00:00 2001 From: Las Zenow Date: Tue, 16 Apr 2013 13:39:22 +0200 Subject: [PATCH] Separate router initialization into it's own function --- trantor.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/trantor.go b/trantor.go index 9ad1131..00e7053 100644 --- a/trantor.go +++ b/trantor.go @@ -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)) }