mirror of
https://github.com/pomerium/pomerium.git
synced 2025-04-30 19:06:33 +02:00
19 lines
586 B
Go
19 lines
586 B
Go
package httputil // import "github.com/pomerium/pomerium/internal/httputil"
|
|
|
|
import (
|
|
"net/http"
|
|
)
|
|
|
|
// HealthCheck is a simple healthcheck handler that responds to GET and HEAD
|
|
// http requests.
|
|
func HealthCheck(w http.ResponseWriter, r *http.Request) {
|
|
if r.Method != http.MethodGet && r.Method != http.MethodHead {
|
|
http.Error(w, http.StatusText(http.StatusMethodNotAllowed), http.StatusMethodNotAllowed)
|
|
return
|
|
}
|
|
w.Header().Set("Content-Type", "text/plain")
|
|
w.WriteHeader(http.StatusOK)
|
|
if r.Method == http.MethodGet {
|
|
w.Write([]byte(http.StatusText(http.StatusOK)))
|
|
}
|
|
}
|