All checks were successful
Deploy to K8s / deploy (push) Successful in 10s
- Add web/api/handler.go: Handler struct wiring Sources+Config into ServeAdults, ServeJuniors, ServePayments, ServeVersion - Add web/api/build_common.go: getMonthLabels, groupRawPaymentsByPerson, settledBalance, domain-to-wire converters, ensureSlice generic helper - Add web/api/build_adults.go: buildAdultsResponse + buildAdultMemberRow mirroring scripts/views.py:build_adults_view_model - Add web/api/build_juniors.go: buildJuniorsResponse + buildJuniorMemberRow mirroring scripts/views.py:build_juniors_view_model, including "?" sentinel and :NJ,MA breakdown - Add web/api/build_payments.go: buildPaymentsResponse with Unmatched/Unknown bucket - Extend reconcile.FeeData/MonthData with IsUnknown, JuniorAttendance, AdultAttendance - Extend reconcile.Transaction with ManualFix, VS, BankID, SyncID for raw_payments wire field - Export membership.AdultMergedMonths and JuniorMergedMonths - Update sources.go to propagate new FeeData fields and parse extra transaction columns - Wire sources+cfg into web.Run; register /api/* routes via Go 1.22 method+path patterns - Fix pre-existing gofumpt formatting in fio_test.go and fio_table.go Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
49 lines
1.4 KiB
Go
49 lines
1.4 KiB
Go
package web
|
|
|
|
import (
|
|
"fmt"
|
|
"fuj-management/go/internal/config"
|
|
"fuj-management/go/internal/services/membership"
|
|
"fuj-management/go/internal/web/api"
|
|
"fuj-management/go/internal/web/middleware"
|
|
"log/slog"
|
|
"net/http"
|
|
)
|
|
|
|
// BuildInfo carries the linker-injected build metadata.
|
|
type BuildInfo struct {
|
|
Version string
|
|
Commit string
|
|
BuildDate string
|
|
}
|
|
|
|
// Run registers routes and starts the HTTP server on addr.
|
|
func Run(logger *slog.Logger, addr string, build BuildInfo, sources membership.Sources, cfg config.Config) error {
|
|
h := &api.Handler{
|
|
BuildVersion: build.Version,
|
|
BuildCommit: build.Commit,
|
|
BuildDate: build.BuildDate,
|
|
Sources: sources,
|
|
Config: cfg,
|
|
Logger: logger,
|
|
}
|
|
|
|
mux := http.NewServeMux()
|
|
mux.HandleFunc("GET /{$}", helloHandler(build))
|
|
mux.HandleFunc("GET /api/version", h.ServeVersion)
|
|
mux.HandleFunc("GET /api/adults", h.ServeAdults)
|
|
mux.HandleFunc("GET /api/juniors", h.ServeJuniors)
|
|
mux.HandleFunc("GET /api/payments", h.ServePayments)
|
|
|
|
logger.Info("starting server", "addr", addr)
|
|
return http.ListenAndServe(addr, middleware.RequestTimer(logger, mux))
|
|
}
|
|
|
|
func helloHandler(build BuildInfo) http.HandlerFunc {
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
|
|
fmt.Fprintf(w, "fuj-go ok\nversion: %s\ncommit: %s\nbuilt: %s\n",
|
|
build.Version, build.Commit, build.BuildDate)
|
|
}
|
|
}
|