- Add [sso] config section with redirect_uri - Create mcdsl/sso client when SSO is configured - Add /login (landing page), /sso/redirect, /sso/callback routes - Add /logout route - Update login template with SSO landing page variant - Bump mcdsl to v1.6.0 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
49 lines
1.4 KiB
Go
49 lines
1.4 KiB
Go
// Package health provides standard health check implementations for
|
|
// Metacircular services, supporting both REST and gRPC.
|
|
package health
|
|
|
|
import (
|
|
"database/sql"
|
|
"encoding/json"
|
|
"net/http"
|
|
|
|
"google.golang.org/grpc"
|
|
"google.golang.org/grpc/health"
|
|
healthpb "google.golang.org/grpc/health/grpc_health_v1"
|
|
)
|
|
|
|
// Handler returns an http.HandlerFunc that checks database connectivity.
|
|
// It returns 200 {"status":"ok"} if the database is reachable, or
|
|
// 503 {"status":"unhealthy","error":"..."} if the ping fails.
|
|
//
|
|
// Mount it on whatever path the service uses (typically /healthz or
|
|
// /v1/health).
|
|
func Handler(database *sql.DB) http.HandlerFunc {
|
|
return func(w http.ResponseWriter, _ *http.Request) {
|
|
w.Header().Set("Content-Type", "application/json")
|
|
|
|
if err := database.Ping(); err != nil {
|
|
w.WriteHeader(http.StatusServiceUnavailable)
|
|
_ = json.NewEncoder(w).Encode(map[string]string{
|
|
"status": "unhealthy",
|
|
"error": err.Error(),
|
|
})
|
|
return
|
|
}
|
|
|
|
w.WriteHeader(http.StatusOK)
|
|
_ = json.NewEncoder(w).Encode(map[string]string{
|
|
"status": "ok",
|
|
})
|
|
}
|
|
}
|
|
|
|
// RegisterGRPC registers the standard gRPC health checking service
|
|
// (grpc.health.v1.Health) on the given gRPC server. The health server
|
|
// is set to SERVING status immediately.
|
|
func RegisterGRPC(srv *grpc.Server) {
|
|
hs := health.NewServer()
|
|
hs.SetServingStatus("", healthpb.HealthCheckResponse_SERVING)
|
|
healthpb.RegisterHealthServer(srv, hs)
|
|
}
|