diff options
author | xengineering <me@xengineering.eu> | 2023-02-09 21:54:40 +0100 |
---|---|---|
committer | xengineering <me@xengineering.eu> | 2023-02-09 21:55:36 +0100 |
commit | 5c41fda52bfe6c0ab898a284ed9373f12a04c92b (patch) | |
tree | 31849181f8af554e6aa1eb597ac8901b3b2bff45 | |
parent | 4f0c5b2e5eb1277e6b5a6ba347ce08fd34cf1326 (diff) | |
download | ceres-5c41fda52bfe6c0ab898a284ed9373f12a04c92b.tar ceres-5c41fda52bfe6c0ab898a284ed9373f12a04c92b.tar.zst ceres-5c41fda52bfe6c0ab898a284ed9373f12a04c92b.zip |
Split setupRoutes() and runServer()
-rw-r--r-- | main.go | 2 | ||||
-rw-r--r-- | router.go | 6 |
2 files changed, 6 insertions, 2 deletions
@@ -17,5 +17,5 @@ func main() { db := InitDatabase(config.Database) // start web server - RunServer(config.Http, &db) + runServer(config.Http, &db) } @@ -6,7 +6,7 @@ import ( "net/http" ) -func RunServer(config HttpConfig, db *Database) { +func setupRoutes(config HttpConfig, db *Database) { http.HandleFunc("/", indexMux(db, config.Templates)) http.HandleFunc("/recipe", recipeMux(db, config.Templates)) @@ -15,7 +15,11 @@ func RunServer(config HttpConfig, db *Database) { 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)) |