mirror of
https://github.com/TwiN/gatus.git
synced 2025-01-08 23:18:56 +01:00
Rename function to PrependWithContextRoot
This commit is contained in:
parent
c827eb7948
commit
9af8a02f05
@ -60,9 +60,9 @@ func (web *webConfig) SocketAddress() string {
|
||||
return fmt.Sprintf("%s:%d", web.Address, web.Port)
|
||||
}
|
||||
|
||||
// AppendToContexRoot appends the given string to the context root
|
||||
// AppendToContexRoot takes care of having only one "/" character at
|
||||
// PrependWithContextRoot appends the given string to the context root
|
||||
// PrependWithContextRoot takes care of having only one "/" character at
|
||||
// the join point and exactly on "/" at the end
|
||||
func (web *webConfig) AppendToContexRoot(fragment string) string {
|
||||
func (web *webConfig) PrependWithContextRoot(fragment string) string {
|
||||
return web.ContextRoot + strings.Trim(fragment, "/") + "/"
|
||||
}
|
||||
|
6
main.go
6
main.go
@ -31,12 +31,12 @@ func main() {
|
||||
}
|
||||
// favicon needs to be always served from the root
|
||||
http.HandleFunc("/favicon.ico", favIconHandler)
|
||||
http.HandleFunc(cfg.Web.AppendToContexRoot("/api/v1/results"), resultsHandler)
|
||||
http.HandleFunc(cfg.Web.AppendToContexRoot("/health"), healthHandler)
|
||||
http.HandleFunc(cfg.Web.PrependWithContextRoot("/api/v1/results"), resultsHandler)
|
||||
http.HandleFunc(cfg.Web.PrependWithContextRoot("/health"), healthHandler)
|
||||
http.Handle(cfg.Web.ContextRoot, GzipHandler(http.StripPrefix(cfg.Web.ContextRoot, http.FileServer(http.Dir("./static")))))
|
||||
|
||||
if cfg.Metrics {
|
||||
http.Handle(cfg.Web.AppendToContexRoot("/metrics"), promhttp.Handler())
|
||||
http.Handle(cfg.Web.PrependWithContextRoot("/metrics"), promhttp.Handler())
|
||||
}
|
||||
log.Printf("[main][main] Listening on %s%s\n", cfg.Web.SocketAddress(), cfg.Web.ContextRoot)
|
||||
go watchdog.Monitor(cfg)
|
||||
|
Loading…
Reference in New Issue
Block a user