-
Notifications
You must be signed in to change notification settings - Fork 90
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
Expand HTTPRoute Matching #109
Conversation
Adds an njs module to support routing requests based on the HTTP method, headers, and or query parameters of the request. Currently, only processes one HTTPRouteMatch per route.
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.
Hi @kate-osborn
This looks great! Please see some questions and suggestions
Also pins the version of prettier to 2.6.2
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.
@kate-osborn
The changes look good! Just a few suggestions/comments for the new stuff
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.
👍
Proposed changes
Adds support for
HTTPRoute
matching based on headers, query parameters, and method.The generator package now generates both an external and internal location block for routes that have headers, query parameters, and/or a method defined as a match condition.
The external location block handles the request for a given path and invokes the
httpmatches
njs module to handle the matching logic. The njs module will compare the request object's attributes to the match conditions. If the request satisfies all the match conditions, the request is routed to the internal location block. Otherwise, a 405 or 404 is returned.The internal location block proxies the request to the backend service.
If a route's
HTTPRouteMatch
only defines apath
, no internal location block is generated. In this case, the njs module is not called, and the external location block will proxy the request to the backend service.Other notes:
Limitations and future work:
HTTPRouteMatch
will be processed for a given path. Eventually we will need to support multiple routes per path and multipleHTTPRouteMatches
per path.Exact
matching for headers and query parameters is supported.HTTPRouteMatch
fields. We will need to add custom validation for headers and query parameters.Checklist
Before creating a PR, run through this checklist and mark each as complete.