router.go 622 B

12345678910111213141516171819
  1. package httpapi
  2. import "net/http"
  3. // NewRouter wires the HTTP surface. The payroll cycle endpoint is the only
  4. // entry point into the hand-written use-case layer.
  5. func NewRouter(h *PayrollHandler) http.Handler {
  6. mux := http.NewServeMux()
  7. mux.HandleFunc("POST /v1/payroll/cycles/{cycleID}/run", h.RunCycle)
  8. mux.HandleFunc("GET /v1/payroll/cycles/{cycleID}", h.GetCycle)
  9. mux.HandleFunc("GET /v1/payroll/cycles/{cycleID}/payslips", h.ListPayslips)
  10. mux.HandleFunc("GET /healthz", health)
  11. return mux
  12. }
  13. func health(w http.ResponseWriter, _ *http.Request) {
  14. w.WriteHeader(http.StatusOK)
  15. _, _ = w.Write([]byte("ok"))
  16. }