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: adding global middleware support to Server #11

Merged
merged 2 commits into from
Sep 18, 2024

Conversation

gabrielluizsf
Copy link
Contributor

  • Added globalMiddlewares field to Server struct to allow middleware execution for all routes.
  • Introduced Use method to register global middlewares.
  • Refactored Listen method by extracting route registration logic into registerRoutes to handle both global and route-specific middlewares.
  • Simplified middleware chaining through the new registerMiddlewares helper function.

- Added `globalMiddlewares` field to `Server` struct to allow middleware execution for all routes.
- Introduced `Use` method to register global middlewares.
- Refactored `Listen` method by extracting route registration logic into `registerRoutes` to handle both global and route-specific middlewares.
- Simplified middleware chaining through the new `registerMiddlewares` helper function.
- Added `TestUse` to verify that global middlewares are correctly executed for all routes.
- Test ensures that middleware logs request method and path, and sets custom response header.
- Verifies middleware interaction with route-specific handler for `/login/{name}`.
@i9si i9si merged commit c052039 into i9si-sistemas:main Sep 18, 2024
1 check passed
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.

2 participants