/db/_design/design-doc/_rewrite/path¶ANY /{db}/_design/{ddoc}/_rewrite/{path}¶Rewrites the specified path by rules defined in the specified design document.
The rewrite rules are defined in array field of the design document
called rewrites. Each rule is an object with next structure:
"*"The to``and ``from paths may contains string patterns with leading
: or * characters.
For example: /somepath/:var/*
/var are converted in atom"" are converted to '' atom/ in request url in a list
of token'*' in single quotes) will match any number of tokens,
but may only be present as the last pathterm in a pathspecThe pattern matching is done by first matching the HTTP request method to a
rule. method is equal to "*" by default, and will match any HTTP
method. It will then try to match the path to one rule. If no rule matches,
then a 404 Not Found response returned.
Once a rule is found we rewrite the request url using the to and
query fields. The identified token are matched to the rule and will
replace var. If '*' is found in the rule it will contain the remaining
part if it exists.
Examples:
| Rule | Url | Rewrite to | Tokens |
|---|---|---|---|
|
/a | /some | |
|
/a/b/c | /some/b/c | |
|
/a/b?k=v | /some?k=v | k=v |
|
/a/b | /some/b?var=b | var=b |
| {“from”: “/a/:foo/”, “to”: “/some/:foo/”} | /a/b/c | /some/b/c?foo=b | foo=b |
|
/a/b | /some/?k=b&foo=b | foo=b |
|
/a?foo=b | /some/?b&foo=b | foo=b |
Request method, header, query parameters, request payload and response body are depended on endpoint to which url will be rewritten.
| Parameters: |
|
|---|