Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/missionmatch / internal/modules/commandcenter/handler.go |
| Date | Not specified in source |
| Repository | Janady13/missionmatch |
| Revision | 39df94f92b2a33f852481fe1954dabed841524bb |
| Branch | w0-aedt-compliance |
| Path or archive member | internal/modules/commandcenter/handler.go |
| Original SHA-256 | 0075e210b29c82bdc911b3856c80a42af630a4e8af2c09e0070e43a3bf6111cb |
| Git blob SHA | 878eba6a9f85be5a8b83a7fce05d39d8560fc214 |
| Reading-copy SHA-256 | 0075e210b29c82bdc911b3856c80a42af630a4e8af2c09e0070e43a3bf6111cb |
Recovered source transcript
Download complete source text ↓50 lines · 1.3 KB
package commandcenter
import (
"encoding/json"
"errors"
"net/http"
"time"
"github.com/go-chi/chi/v5"
"github.com/missionworkforce/missionmatch/internal/platform/tenant"
)
// Handler serves the Workforce Command Center endpoint.
type Handler struct{ svc *Service }
func NewHandler(svc *Service) *Handler { return &Handler{svc: svc} }
// Routes mounts GET /command-center under the tenant-scoped group.
func (h *Handler) Routes(r chi.Router) {
r.Get("/command-center", h.get)
}
func (h *Handler) get(w http.ResponseWriter, r *http.Request) {
asOf := h.svc.clock()
if q := r.URL.Query().Get("as_of"); q != "" {
if t, err := time.Parse("2006-01-02", q); err == nil {
asOf = t
}
}
v, err := h.svc.CommandCenter(r.Context(), asOf)
if err != nil {
w.Header().Set("Content-Type", "application/json")
switch {
case errors.Is(err, tenant.ErrNoTenant):
w.WriteHeader(http.StatusForbidden)
_, _ = w.Write([]byte(`{"error":"no validated tenant"}`))
case errors.Is(err, ErrNoDatabase):
w.WriteHeader(http.StatusServiceUnavailable)
_, _ = w.Write([]byte(`{"error":"database not configured"}`))
default:
w.WriteHeader(http.StatusInternalServerError)
_, _ = w.Write([]byte(`{"error":"internal error"}`))
}
return
}
w.Header().Set("Content-Type", "application/json")
_ = json.NewEncoder(w).Encode(v)
}