29 lines
807 B
Go
29 lines
807 B
Go
package httpapi
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
)
|
|
|
|
// New is the operational shell. Product routes will be added only with their
|
|
// persistence, authentication and provider adapters, never simulated success.
|
|
func New() http.Handler {
|
|
mux := http.NewServeMux()
|
|
mux.HandleFunc("GET /healthz", func(w http.ResponseWriter, r *http.Request) {
|
|
write(w, http.StatusOK, "ok")
|
|
})
|
|
mux.HandleFunc("GET /readyz", func(w http.ResponseWriter, r *http.Request) {
|
|
write(w, http.StatusServiceUnavailable, "not_configured")
|
|
})
|
|
return mux
|
|
}
|
|
|
|
func write(w http.ResponseWriter, status int, value string) {
|
|
w.Header().Set("Content-Type", "application/json")
|
|
w.Header().Set("Cache-Control", "no-store")
|
|
w.WriteHeader(status)
|
|
_ = json.NewEncoder(w).Encode(struct {
|
|
Status string `json:"status"`
|
|
}{value})
|
|
}
|