Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: improve router #817

Merged
merged 3 commits into from
Jul 8, 2024
Merged

refactor!: improve router #817

merged 3 commits into from
Jul 8, 2024

Conversation

pi0
Copy link
Member

@pi0 pi0 commented Jul 8, 2024

This a followup PR on #809 to improve router interface.

The internal code had been rewritten to leverage a much cleaner class pattern and rou3 was upgraded to v0.2.x with a new (method, path) signature.

Router public changes (#787):

  • router.use(path, handler) is deprecated. Use router.all(path, handler) instead.
  • (!!) router.add(path, method: Method | Method[] signature is changed to `router.add(method: Method, path)
  • app.resolve and handler.__resolve signature changes from (path) to (method, path).
  • Router resolver allows resolving params as well (wanted feature for websocket users)

Type changes:

  • RouteNode type is changed to RouterEntry
  • While router.add allows lowercase methods, we prefer upper-case (consistent with web Request normalization) in internal types (HTTPMethod)
  • CreateRouterOptions type is renamed to RouterOptions

@pi0 pi0 self-assigned this Jul 8, 2024
@pi0 pi0 marked this pull request as ready for review July 8, 2024 12:14
@pi0 pi0 merged commit 8d124ed into main Jul 8, 2024
3 checks passed
@pi0 pi0 deleted the refactor/router branch July 8, 2024 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant