-
Notifications
You must be signed in to change notification settings - Fork 171
feat(event-handler): add middleware registration and composition to rest handler #4428
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
Conversation
f5ba571
to
b327588
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only left a couple notes, great work!
b327588
to
7c61fb9
Compare
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff!
After we're done with the feature, let's see if we can bring down the code duplication in the unit test files a bit.
Summary
This PR adds the functionality to register middleware and to compose mutliple middlewares to create reusable middleware stacks.
Note: currently there is no way to alter the response inside a middleware function, this will be done in the next PR.
Changes
1. Middleware Composition Logic (
src/rest/utils.ts
)composeMiddleware()
function for chaining middleware executionnext()
calls2. Router Integration (
src/rest/BaseRouter.ts
)use()
method for middleware registrationresolve()
method to execute middleware chain before route handlers3. Added unit tests (
tests/unit/rest/BaseRouter.test.ts
)next()
and in handlersnext()
calls, middleware not callingnext()
this
scopeIssue number: closes #4427
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.