oficina / sheets Public

Fix round 1: floor the go directive, disclaim the app-level healthz

go.mod pinned go 1.26.5 (this machine's exact toolchain) instead of the
plan's stated floor of 1.25 or later; go mod tidy normalizes the
directive to 1.25.0, matching rastrillo's own go.mod floor.

Comment App.Router()'s /healthz and TestHealthz to say plainly that
rastrillo.Serve's outer mux answers /healthz in a deployed instance,
not this route — Go 1.22+ ServeMux prefers the outer mux's exact
"GET /healthz" pattern over this router's "/" mount. The route and its
test stay: they're the seam later tasks mount on and let App's own
router be tested in isolation, but the passing test should not read as
proof of the production health check.
Paul Campbell 0c85471b6435ff14ad5bbc020d338fba9032601e parent 2e676e5
3 files changed, +13 −1
  • go.mod +1 −1
  • internal/sheets/app.go +7 −0
  • internal/sheets/app_test.go +5 −0
diff --git a/go.mod b/go.mod
index 8dc0d7a..d6b41b9 100644
--- a/go.mod
+++ b/go.mod
@@ -1,6 +1,6 @@
module amadan.net/oficina/sheets
-go 1.26.5
+go 1.25.0
require (
github.com/carlosframework/rastrillo v0.20.0
diff --git a/internal/sheets/app.go b/internal/sheets/app.go
index 5a4b266..115d8bc 100644
--- a/internal/sheets/app.go
+++ b/internal/sheets/app.go
@@ -20,6 +20,13 @@ func New(db *gorm.DB) *App { return &App{db: db} }
// Router returns the mounted handler.
func (a *App) Router() http.Handler {
r := chi.NewRouter()
+ // This /healthz is NOT what answers in a deployed instance:
+ // rastrillo.Serve registers its own GET /healthz on the outer mux
+ // (serve.go's buildHandler), and Go 1.22+ http.ServeMux prefers that
+ // exact pattern over this router's "/" mount, so the outer one wins
+ // every time in production. It exists here so App's own router is
+ // testable in isolation (see TestHealthz) and as the seam later
+ // routes mount alongside.
r.Get("/healthz", func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusOK)
})
diff --git a/internal/sheets/app_test.go b/internal/sheets/app_test.go
index 29905ae..b327c56 100644
--- a/internal/sheets/app_test.go
+++ b/internal/sheets/app_test.go
@@ -6,6 +6,11 @@ import (
"testing"
)
+// TestHealthz exercises App.Router()'s own /healthz in isolation via
+// httptest — it does NOT prove what a deployed instance answers. In
+// production rastrillo.Serve's outer mux registers its own GET /healthz
+// ahead of this one and wins (see the comment on Router in app.go); this
+// test only proves the app's router itself is wired and reachable.
func TestHealthz(t *testing.T) {
app := New(nil)
req := httptest.NewRequest(http.MethodGet, "/healthz", nil)