Commit 3a9e0a2
committed
fix: apply request macros to every incoming request in
`requestMacroRegistry` defines `bearerToken()`, `input()`, `has()`,
`missing()`, `filled()`, `only()`, `except()`, `wantsJson()`, `isAjax()`,
`ip()`, `userAgent()`, `header()`, etc. — but `applyMacros()` was never
called from the live request flow. Macros only attached when callers
manually invoked `RequestHelpers.withMacros(req)` or `RequestHelpers.create(...)`.
Effect: middleware and handlers calling `request.bearerToken()` etc. blew up
with `TypeError: request.bearerToken is not a function` because the macros
weren't on the request. Reproduced with the Stacks `Auth` middleware pulling
the bearer token off an authenticated request.
Fix: call `RequestWithMacros.applyMacros(enhancedReq)` inside `enhanceRequest`
right before the cookie utility is attached. Macros run first; the cookie
utility object then overrides the `cookies` macro (the macro returns a plain
record while consumers expect the get/set/delete object form).
All 359 existing tests pass.enhanceRequest
1 parent ca2fbdb commit 3a9e0a2
1 file changed
Lines changed: 8 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
333 | 334 | | |
334 | 335 | | |
335 | 336 | | |
336 | | - | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
337 | 344 | | |
338 | 345 | | |
339 | 346 | | |
| |||
0 commit comments