refactor(http): deepen route registration into per-feature modules#142
Merged
Conversation
server.go no longer imports any feature package. Each feature (auth, secrets, transit, tokenization) owns a Module in its http package that registers its own routes next to its handlers, implementing the new RouteRegistrar seam. The composition root builds every middleware, assembles the []RouteRegistrar, and hands it to a feature-agnostic SetupRouter; RouterDeps and the four register*Routes funcs are gone. The import direction reverses to feature -> internal/http. A route-manifest golden test (server_routes_test.go) locks the 35 method+path pairs so the relocation is provably behavior-preserving. CLI access to the container is untouched. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Deepens the seam between feature modules and the HTTP server.
internal/http/server.gowas the single most-churned file in the repo (13 edits in the last 40 commits) because every feature change had to touch it, plusRouterDeps(a 13-field inventory duplicated acrossdi.goandserver.go) and four near-identicalregister*Routesfuncs.After this change, each feature owns its route registration next to its handlers, and
server.goimports no feature package.What changed
internal/http(imports only gin + metrics):RouteRegistrarinterface +RouteMiddlewares{Auth, RateLimit}bundle.SetupRouteris now feature-agnostic — it builds the global middleware chain and loops over a[]RouteRegistrar.Modules (auth,secrets,transit,tokenization) — each captures its handlers + authorizer + business metrics and registers its own routes. Verbatim relocation of the existing gin stanzas; no behavior change. The auth module owns the/tokenirregular layout (no-auth + IP-based rate limit).di.gobuilds all middleware (auth, rate-limit, token-rate-limit, authorizer), assembles the registrars, and calls the newSetupRouter. CLI access to the container is untouched.RouterDeps+ the fourregister*Routesfuncs (~320 lines).http → featuresbecomesfeatures → internal/http(no cycle).CONTEXT.md: recordedRoute Module,RouteRegistrar,RouteMiddlewares.A follow-up
chorecommit bumps Go 1.26.3 → 1.26.5 and updates dependencies.Test plan
server_routes_test.go) — asserts the full set of 35method + pathpairs is byte-identical before and after the relocation.make test(race) — 1250 pass.make test-integration(serial, DB up) — green, including the auth + authz + business-metrics end-to-end flows.make lint— golangci clean.server.goimports no feature-http package.🤖 Generated with Claude Code