From 7e517ada827abc2658bb07347bc656c10860e091 Mon Sep 17 00:00:00 2001 From: xengineering Date: Sat, 11 Feb 2023 13:02:41 +0100 Subject: Switch webserver to global config struct --- server.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'server.go') diff --git a/server.go b/server.go index ef7397d..f7f67f4 100644 --- a/server.go +++ b/server.go @@ -6,21 +6,21 @@ import ( "net/http" ) -func setupRoutes(config HttpConfig, db *Database) { +func setupRoutes(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)) + http.HandleFunc("/", indexMux(db)) + http.HandleFunc("/recipe", recipeMux(db)) + http.HandleFunc("/recipe/edit", recipeEditMux(db)) + http.HandleFunc("/recipe/image", recipeImageMux()) + http.HandleFunc("/add_recipes", addRecipesMux(db)) + http.HandleFunc("/static/style.css", staticStyleMux()) + http.HandleFunc("/favicon.ico", faviconMux()) } -func runServer(config HttpConfig, db *Database) { +func runServer(db *Database) { - setupRoutes(config, db) - address := config.Host + ":" + config.Port + setupRoutes(db) + address := config.Http.Host + ":" + config.Http.Port log.Println("Binding to 'http://" + address) log.Fatal(http.ListenAndServe(address, nil)) } -- cgit v1.2.3-70-g09d2