mirror of
https://github.com/lukaszraczylo/traefikoidc.git
synced 2026-10-17 04:37:48 +00:00
25 lines
560 B
Go
25 lines
560 B
Go
package main
|
|
|
|
import "net/http"
|
|
|
|
// readyReporter is satisfied by *traefikoidc.TraefikOidc via its Ready() method.
|
|
type readyReporter interface {
|
|
Ready() bool
|
|
}
|
|
|
|
func newHealthzHandler() http.Handler {
|
|
return http.HandlerFunc(func(rw http.ResponseWriter, _ *http.Request) {
|
|
rw.WriteHeader(http.StatusOK)
|
|
})
|
|
}
|
|
|
|
func newReadyzHandler(r readyReporter) http.Handler {
|
|
return http.HandlerFunc(func(rw http.ResponseWriter, _ *http.Request) {
|
|
if r.Ready() {
|
|
rw.WriteHeader(http.StatusOK)
|
|
return
|
|
}
|
|
rw.WriteHeader(http.StatusServiceUnavailable)
|
|
})
|
|
}
|