http: Use own server

This commit is contained in:
Thorben Günther 2023-07-14 12:47:22 +02:00
parent fab51ab54b
commit e0e1281ec3
No known key found for this signature in database
GPG key ID: 415CD778D8C5AFED

View file

@ -453,6 +453,10 @@ func main() {
logger.Infof("Listening on %s, ntfy-alertmanager %s", cfg.HTTPAddress, version)
mux := http.NewServeMux()
httpServer := &http.Server{
Addr: cfg.HTTPAddress,
Handler: mux,
}
if cfg.User != "" && cfg.Password != "" {
logger.Info("Enabling HTTP Basic Authentication")
@ -466,5 +470,5 @@ func main() {
if _, ok := c.(*cache.MemoryCache); ok {
go bridge.runCleanup()
}
logger.Fatal(http.ListenAndServe(cfg.HTTPAddress, mux))
logger.Fatal(httpServer.ListenAndServe())
}