mirror of
https://github.com/davidallendj/configurator.git
synced 2025-12-20 03:27:02 -07:00
feat: added healthcheck to server
This commit is contained in:
parent
7de2dcc4e8
commit
b0b52dc432
1 changed files with 14 additions and 0 deletions
|
|
@ -116,6 +116,7 @@ func (s *Server) Serve() error {
|
|||
|
||||
// protected routes if using auth
|
||||
r.HandleFunc("/generate", s.Generate(opts...))
|
||||
r.HandleFunc("/status", s.GetStatus)
|
||||
r.Post("/targets", s.createTarget)
|
||||
})
|
||||
} else {
|
||||
|
|
@ -225,6 +226,19 @@ func (s *Server) loadTargets() {
|
|||
}
|
||||
}
|
||||
|
||||
func (s *Server) GetStatus(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
data := map[string]any{
|
||||
"code": 200,
|
||||
"message": "Configurator is healthy",
|
||||
}
|
||||
err := json.NewEncoder(w).Encode(data)
|
||||
if err != nil {
|
||||
fmt.Printf("failed to encode JSON: %v\n", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// Create a new target with name, generator, templates, and files.
|
||||
//
|
||||
// Example:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue