feat: HTTP layer with strict-server handlers and JWT middleware#11
Conversation
Wire up the generated StrictServerInterface with typed request/response objects. JWT auth runs as a StrictMiddlewareFunc applied selectively to protected operations (postAuthLogout, postAuthLogoutAll) rather than a blanket route group. - server.go: NewServer wires strict handler + middleware chain (RequestID → Logging → gen.Handler) - middleware.go: RequestID and Logging middleware; context keys for request ID, logger, userID, jfUserID - handlers_auth.go: full StrictServerInterface implementation mapping auth.Service errors to typed JSON responses - errors.go: writeError helper using gen.ErrorErrorCode constants - middleware_test.go: JWT middleware unit tests + compile-time interface check (var _ gen.StrictServerInterface = (*Server)(nil)) - auth/jwt.go: IssueAccessTokenForTest seam for middleware tests Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Claude finished @koinsaari's task in 2m 23s —— View job Code Review
SummaryTwo blocking issues found. No import cycle. JWT keyfunc correctly validates signing method before returning the key ( 🔴 Important — Wrong error code for missing
|
@claude this would couple middleware with the generated code. you think it's still a good idea?. server.go already imports gen |
|
Claude finished @koinsaari's task in 40s —— View job You're right to push back on that nit — keeping The key distinction is the type boundary.
The nit stands retracted. Leave it where it is. |
- gen.TokenInvalid for missing bearer header (was gen.TokenExpired) - handler tests for all routes via fakeAuth stub - authService interface on Server for testability without a real DB - guard PostAuthLogoutAll against missing ctxUserID - log errors in ResponseErrorHandlerFunc instead of discarding them Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Claude finished @koinsaari's task in 2m 23s —— View job Code Review — e352b01
SummaryNo blocking issues. Both previous 🔴 findings are resolved. No import cycle. JWT keyfunc correctly validates signing method before returning the key ( ✅ Previous blockers resolvedMissing bearer token error code — No handler tests —
🟡 Nit —
|
Use errors.Is(err, jwt.ErrTokenExpired) so expired tokens get TokenExpired and malformed/bad-signature tokens get TokenInvalid. Add tests for both cases. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Claude finished @koinsaari's task in 1m 50s —— View job Code Review — 7cc820b
SummaryNo blocking issues. The previous 🟡 nit about ✅ Previous nit resolved —
|
Summary
NewServerwires the generatedStrictServerInterfaceinto a middleware chain:RequestID → Logging → gen.Handler(strict)RequestIDandLoggingmiddleware; typed context keys for request ID, logger, userID, jfUserIDStrictServerInterfaceimplementation mappingauth.Serviceerrors to typed JSON error responses using generated constants (gen.InvalidCredentials,gen.AccountLocked, etc.)writeErrorhelper usinggen.ErrorErrorCodeconstantsvar _ gen.StrictServerInterface = (*Server)(nil))IssueAccessTokenForTesttest seam used by middleware testsJWT auth runs as a
StrictMiddlewareFuncapplied selectively to protected operations (postAuthLogout,postAuthLogoutAll) — not a blanket route group.Test plan
go test -race ./internal/http/...passes locally🤖 Generated with Claude Code