Skip to content

Add asHandler extension to Router<Handler> for simplified handler usage #214

Closed

Description

@coderabbitai

Description

This issue tracks the feature implemented in PR #209 to add an asHandler extension to Router<Handler>, enabling routers to be used directly as handlers without wrapping with routeWith.

Feature Summary

  • Adds an asHandler extension method to Router<Handler>
  • Returns a handler that performs routing lookup
  • Provides appropriate responses:
    • 404 when no route matches
    • 405 for method mismatch (includes Allow header)
  • Simplifies common usage patterns where a router is the final handler in a pipeline

Benefits

  • Reduces boilerplate code
  • More intuitive API for simple routing scenarios
  • Maintains existing routing behavior while providing a cleaner interface

Related PR

Requester

@nielsenko


Note: This issue was created after the PR was opened to provide tracking and documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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