Skip to content

Add NewContext.withRequest(Request req) convenience method #193

Closed

Description

@coderabbitai

Currently, when middleware needs to rewrite a request and pass it to the inner handler, it must use the low-level pattern:

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:

NewContext withRequest(Request req)

This would allow the more readable pattern:

final rewrittenRequest = req.copyWith(requestedUri: newRequested);
return await inner(ctx.withRequest(rewrittenRequest));

Context:

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions