-
Notifications
You must be signed in to change notification settings - Fork 157
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
[TT-12871, DX-1784] Add explanation of path ordering before pattern matching #5812
base: master
Are you sure you want to change the base?
Conversation
✅ PS. Pls add /docs/nightly to the end of url
To edit notification comments on pull requests, go to your Netlify site configuration. |
1 similar comment
✅ PS. Pls add /docs/nightly to the end of url
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ PS. Pls add /docs/nightly to the end of url
To edit notification comments on pull requests, go to your Netlify site configuration. |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨No code suggestions found for the PR. |
Having created the ordered list, Tyk will attempt to match the request against the paths (patterns) in the list, starting from the top and moving down the list. | ||
If a match is found, no further checks will be perfomed, so it is important to understand how Tyk orders the patterns to ensure there is no accidental routing to the wrong endpoint. |
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.
Having created the ordered list, Tyk will attempt to match the request against the paths (patterns) in the list, starting from the top and moving down the list. | |
If a match is found, no further checks will be perfomed, so it is important to understand how Tyk orders the patterns to ensure there is no accidental routing to the wrong endpoint. | |
Having created the ordered list, Tyk will attempt to match the request against the paths (patterns) in the list, starting from the top and moving down the list. If a match is found, no further checks will be perfomed, so it is important to understand how Tyk orders the patterns to ensure there is no accidental routing to the wrong endpoint. |
Removed unnecessary newline
|
||
Before attempting to [match](#pattern-matching) the incoming request to the various APIs deployed on Tyk to determine which route should be taken, Tyk will first place all the APIs in order. The order is important because the routing logic will compare the incoming request against each in turn until it finds a match (or returns `HTTP 404` if no match is found). | ||
|
||
On receipt of an API request Tyk firstly creates a list of all APIs and then iterates through the list for each of the following steps: |
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.
I think this statement is incorrect.
Does Ordering
(making a list) happens for every API request, or does it happen when the gateway starts?
If it happens for every request, isn't that inefficient?
1. APIs that don't have a custom domain defined are moved to the end of the list | ||
2. Then among each section (custom domain/no custom domain) it will sort by listen path length (longer paths first) | ||
- note that (dynamic) path parameters are not resolved at this stage so `/api/{category}/user` will rank higher than `/api/123/user` | ||
3. Then, for each listen path it will sort the endpoints using these rules: | ||
- remove path parameters (dynamic segments) in the listen path - for example `/{id}` will be replaced with `/` | ||
- order by the number of segments (count of `/`) from most to least - e.g. `/api/user/profile` before `/api/user` | ||
- if two endpoints differ only by parameters, the non-parameterized goes first - e.g. `/api/user` before `/api/{userId}` | ||
- if two endpoints have the same number of segments, the longer path goes first - e.g. `/api/user-access` before `/api/user` | ||
- for equal length paths, lexicographical order is applied - e.g. `/api/aba` before `/api/abc` |
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.
Though, this lays out all the conditions. A better experience would be adding an embedded app here. Similar to the storage calculator app.
I am creating a Ticket for it.
DX-1784
Preview Link
https://deploy-preview-5812--tyk-docs.netlify.app/docs/nightly/getting-started/key-concepts/url-matching/#pattern-ordering
Description
Adding explanation of URL ordering algorithm
PR Type
Documentation
Description
Changes walkthrough 📝
url-matching.md
Added detailed documentation on path ordering and URL matching.
tyk-docs/content/getting-started/key-concepts/url-matching.md
Tyk orders APIs and endpoints.