Welcome to mirror list, hosted at ThFree Co, Russian Federation.

middleware.go « acme « internal - gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 988e63b7d78a4d65f003b09e8607c1a2cf28563c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package acme

import (
	"net/http"
	// TODO: break this dependency too https://gitlab.com/gitlab-org/gitlab-pages/-/issues/650
	domainCfg "gitlab.com/gitlab-org/gitlab-pages/internal/domain"
)

// AcmeMiddleware handles ACME challenges
func (m *Middleware) AcmeMiddleware(handler http.Handler) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		domain := domainCfg.FromRequest(r)

		if m.ServeAcmeChallenges(w, r, domain) {
			return
		}

		handler.ServeHTTP(w, r)
	})
}