Request Flow
Request Flow
Section titled “Request Flow”Plumego keeps the HTTP path visible from route registration to response write. The important test is simple: a maintainer should be able to point at the file that owns each step.
Flow diagram
Section titled “Flow diagram”1routes.goone method, one path, one handler
2coreroute table plus middleware chain
3routermethod, path, params, groups
4middlewarerequest IDs, tracing, logging, rate limits
5contractWriteResponse or WriteError
1
Register the route
one method, one path, one handler
2
Attach to the app
route table plus middleware chain
3
Match the request
method, path, params, groups
4
Run transport wrappers
request IDs, tracing, logging, rate limits
5
Handle and write
WriteResponse or WriteError
reference/standard-service/internal/app/routes.go -> core route registration -> router method/path match -> transport-only middleware chain -> net/http handler -> contract.WriteResponse or contract.WriteErrorWhat each step owns
Section titled “What each step owns”| Step | Surface | Owns | Should not own |
|---|---|---|---|
| Route registration | internal/app/routes.go |
One method, one path, one handler | Hidden handler discovery |
| Match | router |
Method/path matching, params, groups, reverse routes | Business DTO assembly |
| Wrap | middleware |
Transport-only behavior such as request IDs, tracing, logging, rate limiting | Service lookup or feature wiring |
| Handle | func(http.ResponseWriter, *http.Request) |
Decode input, call explicit app code, choose success or error | Framework-specific handler contracts |
| Write | contract |
Canonical success and error response shape | Feature-specific helper families |
Minimal handler map
Section titled “Minimal handler map”func (h APIHandler) Greet(w http.ResponseWriter, r *http.Request) { name := r.URL.Query().Get("name") if name == "" { _ = contract.WriteError(w, r, contract.NewErrorBuilder(). Type(contract.TypeRequired). Detail("field", "name"). Message("name is required"). Build()) return } _ = contract.WriteResponse(w, r, http.StatusOK, greetResponse{Message: "hello, " + name}, nil)}Review checklist
Section titled “Review checklist”| Question | Where to check |
|---|---|
| Where did this endpoint get registered? | reference/standard-service/internal/app/routes.go or the application route file |
| Which middleware layers run before it? | The app/core wiring around the handler |
| Where are dependencies created? | Application constructors, not request context service lookup |
| Which response shape is used? | contract.WriteResponse for success; contract.WriteError for errors |
| Is this still standard-library compatible? | Handler parameters remain http.ResponseWriter and *http.Request |
What Plumego avoids
Section titled “What Plumego avoids”| Avoided pattern | Reason |
|---|---|
init() handler registration |
Makes endpoint ownership hard to review |
| Context service locators | Hides dependency wiring in request state |
| Feature-specific response helper families | Splits the canonical transport contract |
| Middleware that assembles business DTOs | Blurs transport and application ownership |