gocustomurls/app.go

31 lines
527 B
Go
Raw Normal View History

2024-05-06 07:20:30 +00:00
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,
}
}