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

Allow to unregister a route #51

Merged
merged 5 commits into from
Feb 4, 2022
Merged

Allow to unregister a route #51

merged 5 commits into from
Feb 4, 2022

Conversation

PetrHeinz
Copy link

There was no nice way in the current way of registering routes to disable a certain method.

You need to override the whole route config to eg. disallow POST:

base config:

slim:
  routes:
    'app':
      'some-slug':
        get:
          service: SomeService
          middlewares: [...someMiddlewares]
        post:
          service: SomeService
          middlewares: [...someMiddlewares]

overriding config:

slim:
  routes:
    'app':
      'some-slug!':
        get:
          service: SomeService
          middlewares: [...someMiddlewares]

This leads to repetition and if the base middleware config were to change, you would need to change it in all overriding configs (leading to mistakes).

Imo it should be possible to provide an empty array to disable a route:

suggested overriding config:

slim:
  routes:
    'app':
      'some-slug':
        post!:

@PetrHeinz PetrHeinz enabled auto-merge (squash) February 4, 2022 11:57
@PetrHeinz PetrHeinz merged commit ee29d3c into 5.x Feb 4, 2022
@PetrHeinz PetrHeinz deleted the allow-to-unregister-a-route branch February 4, 2022 13:48
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.

3 participants