26 lines
558 B
Go
26 lines
558 B
Go
package port
|
|
|
|
import (
|
|
"net/http"
|
|
"time"
|
|
|
|
"gitea.dwysokinski.me/twhelp/corev3/internal/health"
|
|
"gitea.dwysokinski.me/twhelp/corev3/internal/health/healthhttp"
|
|
"github.com/go-chi/chi/v5"
|
|
)
|
|
|
|
const metaHandlerTimeout = 5 * time.Second
|
|
|
|
func NewMetaHTTPHandler(h *health.Health) http.Handler {
|
|
r := chi.NewRouter()
|
|
|
|
r.Use(func(next http.Handler) http.Handler {
|
|
return http.TimeoutHandler(next, metaHandlerTimeout, "Timeout")
|
|
})
|
|
|
|
r.Get("/livez", healthhttp.LiveHandler(h).ServeHTTP)
|
|
r.Get("/readyz", healthhttp.ReadyHandler(h).ServeHTTP)
|
|
|
|
return r
|
|
}
|