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

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

import (
	"net/http"
)

// NewMiddleware is serving the application status check
func NewMiddleware(handler http.Handler, statusPath string) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		if r.RequestURI == statusPath {
			w.Header().Set("Cache-Control", "no-store")
			w.Write([]byte("success\n"))

			return
		}

		handler.ServeHTTP(w, r)
	})
}