get acme-challenges over https too

This commit is contained in:
AJ ONeal 2020-11-18 05:13:51 -07:00
parent ebce63c08e
commit e63b99d49b
1 changed files with 15 additions and 11 deletions

View File

@ -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) {