diff options
Diffstat (limited to 'router.go')
-rw-r--r-- | router.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/router.go b/router.go new file mode 100644 index 0000000..6985780 --- /dev/null +++ b/router.go @@ -0,0 +1,27 @@ + +package main + +import ( + "log" + "net/http" +) + +func RunServer(config HttpConfig, db *Database) { + + http.HandleFunc("/", index(db, config.Templates)) + + http.HandleFunc("/recipe", recipe(db, config.Templates)) + + http.HandleFunc("/recipe/edit", recipe_edit(db, config.Templates)) + + http.HandleFunc("/recipe/image", image(config.Storage)) + + http.HandleFunc("/add_recipes", add_recipes(db, config.Storage, config.Static)) + + http.HandleFunc("/static/style.css", static("style.css", config.Static)) + http.HandleFunc("/favicon.ico", static("favicon.ico", config.Static)) + + address := config.Host + ":" + config.Port + log.Println("Binding to 'http://" + address) + log.Fatal(http.ListenAndServe(address, nil)) +} |