package main import ( "fmt" "net/http" ) type Application struct { Config *Config Mux *http.ServeMux Log *LogFile } func (app *Application) routes() { m := http.NewServeMux() m.HandleFunc("/healthcheck", healthcheck) m.HandleFunc("/reloadRules", reloadRules(app.Config)) m.HandleFunc("/", serveLogger(app.Log)(serveRules(app.Config))) app.Mux = m } func (app *Application) Setup(port string) *http.Server { app.routes() return &http.Server{ Addr: fmt.Sprintf(":%s", port), Handler: app.Mux, } }