diff --git a/internal/mgmt/route.go b/internal/mgmt/route.go index 5ed6de9..2657b0b 100644 --- a/internal/mgmt/route.go +++ b/internal/mgmt/route.go @@ -33,21 +33,23 @@ func RouteStatic(r chi.Router) chi.Router { r.Use(middleware.Timeout(15 * time.Second)) r.Use(middleware.Recoverer) - r.Get("/.well-known/acme-challenge/{token}", func(w http.ResponseWriter, r *http.Request) { - //token := chi.URLParam(r, "token") - host := r.Host - if strings.ContainsAny(host, "/:|\\") { - host = "" - } - tokenPath := filepath.Join(tmpBase, host) - - fsrv := http.FileServer(http.Dir(tokenPath)) - fsrv.ServeHTTP(w, r) - }) + r.Get("/.well-known/acme-challenge/{token}", getACMEChallenges) return r } +func getACMEChallenges(w http.ResponseWriter, r *http.Request) { + //token := chi.URLParam(r, "token") + host := r.Host + if strings.ContainsAny(host, "/:|\\") { + host = "" + } + tokenPath := filepath.Join(tmpBase, host) + + fsrv := http.FileServer(http.Dir(tokenPath)) + fsrv.ServeHTTP(w, r) +} + func RouteAll() chi.Router { go func() { @@ -74,6 +76,8 @@ func RouteAll() chi.Router { r.Use(middleware.Timeout(15 * time.Second)) r.Use(middleware.Recoverer) + r.Get("/.well-known/acme-challenge/{token}", getACMEChallenges) + r.Route("/api", func(r chi.Router) { r.Use(func(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {