http: Use own multiplexer
This commit is contained in:
parent
a9fa7e4b23
commit
fab51ab54b
1 changed files with 7 additions and 5 deletions
12
main.go
12
main.go
|
@ -452,17 +452,19 @@ func main() {
|
||||||
|
|
||||||
logger.Infof("Listening on %s, ntfy-alertmanager %s", cfg.HTTPAddress, version)
|
logger.Infof("Listening on %s, ntfy-alertmanager %s", cfg.HTTPAddress, version)
|
||||||
|
|
||||||
|
mux := http.NewServeMux()
|
||||||
|
|
||||||
if cfg.User != "" && cfg.Password != "" {
|
if cfg.User != "" && cfg.Password != "" {
|
||||||
logger.Info("Enabling HTTP Basic Authentication")
|
logger.Info("Enabling HTTP Basic Authentication")
|
||||||
http.HandleFunc("/", bridge.basicAuthMiddleware(bridge.handleWebhooks))
|
mux.HandleFunc("/", bridge.basicAuthMiddleware(bridge.handleWebhooks))
|
||||||
http.HandleFunc("/silences", bridge.basicAuthMiddleware(bridge.handleSilences))
|
mux.HandleFunc("/silences", bridge.basicAuthMiddleware(bridge.handleSilences))
|
||||||
} else {
|
} else {
|
||||||
http.HandleFunc("/", bridge.handleWebhooks)
|
mux.HandleFunc("/", bridge.handleWebhooks)
|
||||||
http.HandleFunc("/silences", bridge.handleSilences)
|
mux.HandleFunc("/silences", bridge.handleSilences)
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := c.(*cache.MemoryCache); ok {
|
if _, ok := c.(*cache.MemoryCache); ok {
|
||||||
go bridge.runCleanup()
|
go bridge.runCleanup()
|
||||||
}
|
}
|
||||||
logger.Fatal(http.ListenAndServe(cfg.HTTPAddress, nil))
|
logger.Fatal(http.ListenAndServe(cfg.HTTPAddress, mux))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue