Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NBHF4R9EAejDJUMdwr6C68
35 lines
956 B
Go
35 lines
956 B
Go
package web
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
)
|
|
|
|
// guidesData füllt guides.html.
|
|
type guidesData struct {
|
|
Guides []Guide
|
|
}
|
|
|
|
func (s *Server) handleGuides(w http.ResponseWriter, r *http.Request, sess *Session) {
|
|
s.renderPage(w, r, http.StatusOK, "guides", sess,
|
|
PageData{Data: guidesData{Guides: Guides(r.UserAgent())}})
|
|
}
|
|
|
|
// handleHealth beantwortet Monitoring-Anfragen ohne Authentifizierung und
|
|
// ohne sensible Details — nur boolesche Zustände und die Sessionzahl.
|
|
func (s *Server) handleHealth(w http.ResponseWriter, r *http.Request) {
|
|
report := HealthReport{OK: true, OPNsense: true, Directory: true}
|
|
if s.d.Health != nil {
|
|
report = s.d.Health.Check(r.Context())
|
|
}
|
|
report.Sessions = s.d.Sessions.Count()
|
|
|
|
status := http.StatusOK
|
|
if !report.OK {
|
|
status = http.StatusServiceUnavailable
|
|
}
|
|
NoStore(w)
|
|
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
|
w.WriteHeader(status)
|
|
json.NewEncoder(w).Encode(report)
|
|
}
|