package main import ( "fmt" "net/http" "time" ) 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, ReadTimeout: 2500 * time.Millisecond, } }