diff options
author | xengineering <me@xengineering.eu> | 2023-02-11 12:32:36 +0100 |
---|---|---|
committer | xengineering <me@xengineering.eu> | 2023-02-11 12:32:36 +0100 |
commit | 817f15a79f2960101644cd282703e9439aef082f (patch) | |
tree | a870c47ebd5270ce5e0ebfe286de8fe76498d505 /server.go | |
parent | c36fef3fcf20f896910b8a96a0477eb522412ce8 (diff) | |
download | ceres-817f15a79f2960101644cd282703e9439aef082f.tar ceres-817f15a79f2960101644cd282703e9439aef082f.tar.zst ceres-817f15a79f2960101644cd282703e9439aef082f.zip |
Rename router.go to server.go
This fits better because this file is the central entry point of the
Ceres webserver.
Diffstat (limited to 'server.go')
-rw-r--r-- | server.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/server.go b/server.go new file mode 100644 index 0000000..ef7397d --- /dev/null +++ b/server.go @@ -0,0 +1,26 @@ + +package main + +import ( + "log" + "net/http" +) + +func setupRoutes(config HttpConfig, db *Database) { + + http.HandleFunc("/", indexMux(db, config.Templates)) + http.HandleFunc("/recipe", recipeMux(db, config.Templates)) + http.HandleFunc("/recipe/edit", recipeEditMux(db, config.Templates)) + http.HandleFunc("/recipe/image", recipeImageMux(config.Storage)) + http.HandleFunc("/add_recipes", addRecipesMux(db, config.Storage, config.Static)) + http.HandleFunc("/static/style.css", staticStyleMux("style.css", config.Static)) + http.HandleFunc("/favicon.ico", faviconMux("favicon.ico", config.Static)) +} + +func runServer(config HttpConfig, db *Database) { + + setupRoutes(config, db) + address := config.Host + ":" + config.Port + log.Println("Binding to 'http://" + address) + log.Fatal(http.ListenAndServe(address, nil)) +} |