Skip to content

Optimize Router.use() to map only the looked-up method entry #188

@coderabbitai

Description

@coderabbitai

Context

In the Router.use() method implementation, there's a TODO comment identifying a potential optimization:

While correct, it would be enough to map only the entry for the method that is actually looked up. However this is not easily achieved with the current implementation.

Currently, when applying a middleware transformation via use(), the implementation maps all HTTP method entries in the _RouterEntry, even though only one method is being looked up at a time. This works correctly but performs unnecessary transformations.

Proposed Optimization

Modify the implementation to apply the mapping function only to the specific method entry being looked up, rather than transforming all method entries upfront.

References

Requested by: @nielsenko

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: routingIssues related to routing.enhancementNew feature or request

    Type

    No type

    Projects

    Status

    Backlog 🗂️

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions