Added healthcheck with /status endpoint

This commit is contained in:
David J. Allen 2024-03-21 14:06:31 -06:00
parent 34a0fdb66b
commit ce2d90bc6a
No known key found for this signature in database
GPG key ID: 717C593FF60A2ACC

View file

@ -56,6 +56,18 @@ func (s *Server) Start(buttons string, provider *oidc.IdentityProvider, client *
target = r.Header.Get("target") target = r.Header.Get("target")
http.Redirect(w, r, "/login", http.StatusSeeOther) http.Redirect(w, r, "/login", http.StatusSeeOther)
}) })
r.HandleFunc("/status", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
data := map[string]any{
"code": 200,
"message": "OPAAL is healthy",
}
err := json.NewEncoder(w).Encode(data)
if err != nil {
fmt.Printf("failed to encode JSON: %v\n", err)
return
}
})
r.HandleFunc("/login", func(w http.ResponseWriter, r *http.Request) { r.HandleFunc("/login", func(w http.ResponseWriter, r *http.Request) {
// add target if query exists // add target if query exists
if r != nil { if r != nil {