gocustomurls/app.go

33 lines
583 B
Go
Raw Normal View History

2024-05-06 07:20:30 +00:00
package main
import (
"fmt"
"net/http"
2024-06-19 20:16:13 +00:00
"time"
2024-05-06 07:20:30 +00:00
)
type Application struct {
Config *Config
Mux *http.ServeMux
Log *LogFile
}
func (app *Application) Routes() {
2024-05-06 07:20:30 +00:00
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()
2024-05-06 07:20:30 +00:00
return &http.Server{
2024-06-19 20:16:13 +00:00
Addr: fmt.Sprintf(":%s", port),
Handler: app.Mux,
ReadTimeout: 2500 * time.Millisecond,
2024-05-06 07:20:30 +00:00
}
}