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

feat: add exclusive option #129

Merged
merged 1 commit into from
Jul 4, 2022
Merged

Conversation

medfreeman
Copy link
Contributor

closes #95

This PR introduces an exclusive boolean option, that makes the router only execute the most specific layer (last match if i understand correctly) when there are multiple route matches for a request url.
c.f.

const mostSpecificLayer = matchedLayers[matchedLayers.length - 1]

It is false by default, so as not introduce a breaking change.

@Townsheriff
Copy link

Why this is not merged?

@etroynov
Copy link
Contributor

Why this is not merged?

because maintainers weren't notified :)

@etroynov
Copy link
Contributor

@@ -31,6 +31,7 @@ Create a new router.
| --- | --- | --- |
| [opts] | <code>Object</code> | |
| [opts.prefix] | <code>String</code> | prefix router paths |
| [opts.exclusive] | <code>Boolean</code> | only run last matched route's controller when there are multiple matches |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you add some examples?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to add examples in another PR that'd be cool! If not no worries.

@titanism
Copy link
Contributor

titanism commented Jul 4, 2022

Please ping us @titanism moving forward for these @etroynov , thank you 🙇

@titanism titanism merged commit c6a8fc8 into koajs:master Jul 4, 2022
@titanism
Copy link
Contributor

titanism commented Jul 4, 2022

We have just published @koajs/router v11.0.0 which resolves this issue. This is mirrored to koa-router as well.

https://github.com/koajs/router/releases/tag/v11.0.0

This project is maintained by Forward Email and Lad.

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.

Multiple routes are executed
4 participants