Repository navigation
routing & rewrite rule
Routing rules or rewrite rules are defined by one or more request templates.
A request template can be further subdivided into the following components
- host template
- path template
querystring templateheaders template- port
- scheme
And the entire request template and all its components can be represented by a string.
http://www.{domain}.com/{action}/{resource}
The parts that can be dynamically matched or replaced are replaced with the names wrapped in curly braces. it calls dynamic segment.
The dynamic segment in the host template and path template can only match one segment by default. For example, the host header such as www.microsoft.com needs three segments to match:
http://{seg1}.{seg2}.{seg3}/
We can use the asterisk suffix to identify this dynamic segment to match multiple segments.
http://{host*}/{path*}
When request template as an upstream template, use it as a matching request and create a route values.
For example, the template just below:
http://{app}.my-site.com/{action}/{resource}
it's matches:
http://login.my-site.com/delete/user
and route values:
- app = login
- action = delete
- resource = user
it's not matches:
http://my-site.com/delete/userhttp://login.my-site.com/delete/user/selfhttps://login.my-site.com/delete/user
When the request template is used as a downstream template, it rewrites the request and replaces the dynamic segment in the template with the route value.
For example, when the above route value is used for this template:
http://api.my-site.com/{app}/{action}/{resource}
It will rewrite the request as:
http://api.my-site.com/login/delete/user