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

Improve the granularity of the method middlewares are assigned to endpoint groups #6

Open
daniel-orlov opened this issue Jul 26, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@daniel-orlov
Copy link
Owner

Is your feature request related to a problem? Please describe.
The current approach to passing middlewares during router initialization has limitations, particularly when we want to configure middlewares on a per-endpoint basis. Presently, it is either an all-or-nothing scenario, where all middlewares are added to a certain endpoint group or none are added at all. This lack of flexibility makes it challenging to customize middleware behavior for specific endpoints.

Describe the solution you'd like
I propose an improvement to the way middlewares are passed during router initialization. The goal is to provide more granular control over middleware configuration for individual endpoints. Here are some suggested options to achieve this:

  1. Endpoint-Specific Middleware: Allow the ability to specify middleware functions or middleware arrays for each endpoint separately. This way, we can define unique middleware chains tailored to the needs of each endpoint.

  2. Middleware Configuration Object: Introduce a configuration object that maps endpoints to the middleware functions or arrays they require. This object would allow us to easily configure middleware chains for different endpoints in a structured manner.

  3. Middleware Priority: Enable setting priorities or ordering for middleware execution at the endpoint level. This ensures that specific middleware functions are executed before others, providing greater control over request processing.

  4. Default Middleware: Retain the option to specify default middlewares that will be applied to all endpoints, but also allow overriding or extending these defaults at the endpoint level.

Describe alternatives you've considered
The current approach of passing middlewares as an array during router initialization is straightforward but lacks the flexibility needed to configure middleware behavior on a per-endpoint basis. The suggested options aim to address this limitation while maintaining backward compatibility.

Additional context
By improving the way middlewares are passed to the router initialization, we can achieve a more flexible and modular approach to request handling. This will enhance the server's ability to handle different types of endpoints with specific middleware requirements. Any further suggestions or considerations for the proposed changes would be valuable for discussion and implementation.

@daniel-orlov daniel-orlov added the enhancement New feature or request label Jul 26, 2023
@daniel-orlov daniel-orlov self-assigned this Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant