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: allow adding endpoints before/after others #4115

Merged
merged 2 commits into from
Nov 22, 2024

Conversation

SychO9
Copy link
Member

@SychO9 SychO9 commented Nov 16, 2024

Similar to #4106

Adds:

  • endpointsBefore('name', fn () => [ ... ])
  • endpointsAfter('name', fn () => [ ... ])
  • endpointsBeforeAll(fn () => [ ... ])

It is currently impossible to add certain endpoints without breaking existing ones. For example, if you have the following endpoints:

  • DELETE /api/discussions/{id}

You would not be able to add custom endpoints with the following paths:

  • DELETE /api/discussions/all

because the pattern which catches the ID for the existing endpoint would also catch all. But if the custom endpoint was added before the existing, the problem would be solved.

Of course another way to solve this would be to enforce that the id parameter is an integer:

  • DELETE /api/discussions/{id:\d+}

but while that might be applicable for this example, other routes such as the GET one allow using slugs.

@SychO9 SychO9 requested a review from a team as a code owner November 16, 2024 16:31
@SychO9 SychO9 self-assigned this Nov 16, 2024
@SychO9 SychO9 added this to the 2.0 milestone Nov 16, 2024
@SychO9 SychO9 merged commit 5e7fbcb into 2.x Nov 22, 2024
28 checks passed
@SychO9 SychO9 deleted the sm/endpoints-extending-before-after branch November 22, 2024 07:45
@SychO9 SychO9 removed this from the 2.0 milestone Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant