diff --git a/web/routes.go b/web/routes.go index 47e4997..eb4c833 100644 --- a/web/routes.go +++ b/web/routes.go @@ -7,9 +7,19 @@ import ( ) // Routes sets up the routes for the server. -func (s *Server) Routes() { - s.Log.Info("Health check handler installed") - s.AddRoute("GET /health", func(w http.ResponseWriter, r *http.Request) { +func (s *Server) Routes(prefix string) { + if prefix != "" { + // Ensure the prefix starts with a slash + if prefix[0] != '/' { + prefix = "/" + prefix + } + // Ensure the prefix starts does not end with a slash + if prefix[len(prefix)-1] == '/' { + prefix = prefix[:len(prefix)-1] + } + } + s.Log.Info(fmt.Sprintf("Health check handler installed: %s/health", prefix)) + s.AddRoute("GET $prefix/health", func(w http.ResponseWriter, r *http.Request) { s.Log.Debug("Health check handler called") w.WriteHeader(http.StatusOK) fmt.Fprintf(w, "Hello, World!")