Currently, when middleware needs to rewrite a request and pass it to the inner handler, it must use the low-level pattern: ```dart final rewrittenRequest = req.copyWith(requestedUri: newRequested); return await inner(rewrittenRequest.toContext(ctx.token)); ``` This pattern is too low-level and error-prone. We should add a convenience method on `NewContext` to simplify this: ```dart NewContext withRequest(Request req) ``` This would allow the more readable pattern: ```dart final rewrittenRequest = req.copyWith(requestedUri: newRequested); return await inner(ctx.withRequest(rewrittenRequest)); ``` **Context:** - Identified in PR #192: https://github.com/serverpod/relic/pull/192 - Comment: https://github.com/serverpod/relic/pull/192#discussion_r2409665572 - Requested by: @nielsenko
Activity