fix(mcp): scaffold middleware order mirrors web.New (Recover first, UUID v7)

This commit is contained in:
2026-08-08 21:56:27 -06:00
parent e1802e4c25
commit 87c5eda1bc
6 changed files with 45 additions and 9 deletions
+14 -2
View File
@@ -277,10 +277,13 @@ func Run() error {
srv := server.New(logger, cfg.Server,
server.WithMiddleware(
mw.RequestID(uuid.NewString),
// Recover outermost, time-ordered request ID, then logging — same order
// as web.New. corsMW (env-gated allow-all) sits before auth so preflight
// OPTIONS short-circuit without hitting the auth middleware.
mw.Recover(logger),
corsMW,
mw.RequestID(newRequestID),
mw.RequestLogger(logger),
corsMW,
authjwt.AuthMiddleware(logger, signer, publicPaths),
authmw.EnrichmentMiddleware(logger, &claimsEnricher{}),
),
@@ -298,6 +301,15 @@ func Run() error {
return lc.Run()
}
// newRequestID returns a time-ordered UUID v7 (falling back to v4), matching web.New.
func newRequestID() string {
id, err := uuid.NewV7()
if err != nil {
return uuid.NewString()
}
return id.String()
}
```
## Feature hook