mirror of
https://github.com/caddyserver/caddy.git
synced 2025-07-09 03:04:57 -04:00
Updated v2: Documentation (markdown)
parent
b974db558b
commit
8738e6ee97
@ -526,10 +526,11 @@ At a high level, major changes from v1 include:
|
||||
|
||||
Request matching is one of the most important parts of configuring a web server. For directives that inject handlers into the middleware chain, you can specify which requests that handler applies to with _matchers_.
|
||||
|
||||
A matcher token comes immediately after the directive token and can be one of three forms:
|
||||
A matcher token comes immediately after the directive token and can be one of these forms:
|
||||
|
||||
1. `*` to match all requests.
|
||||
1. `*` to match all requests (wildcard).
|
||||
2. `/path` starting with a forward slash to match path prefix.
|
||||
3. `=/path` for an exact path match.
|
||||
3. `match:name` to specify a matcher by name.
|
||||
|
||||
If a matcher token is omitted, it is the same as a wildcard matcher. The wildcard matcher is only needed if a matcher token is required; for example, if the argument you want to give a directive is itself a path, it would be ambiguous with a path matcher, so you use a wildcard token: `root * /home/www/mysite`
|
||||
@ -1307,13 +1308,12 @@ Within an HTTP route, you can use additional placeholders:
|
||||
|
||||
If you are using regexp matchers, capture groups (both named and numeric) are available as well:
|
||||
|
||||
{http.matchers.PATH_REGEXP.PATTERN_NAME.CAPTURE_GROUP_NAME}
|
||||
{http.regexp.REGEXP_NAME.CAPTURE_GROUP}
|
||||
|
||||
Replacing:
|
||||
|
||||
- PATH_REGEXP with the name of the matcher that has the regular expression.
|
||||
- PATTERN_NAME with the lower-cased name you gave the pattern.
|
||||
- CAPTURE_GROUP_NAME with the name or index number of the capture group in the regular expression.
|
||||
- REGEXP_NAME with the lower-cased name you gave the regular expression.
|
||||
- CAPTURE_GROUP with the name or index number (starting at 1) of the capture group in the regular expression.
|
||||
|
||||
This will allow you to access capture groups from anywhere in your HTTP route.
|
||||
|
||||
@ -1377,7 +1377,12 @@ Matches requests by request path.
|
||||
"path": []
|
||||
```
|
||||
|
||||
Paths may contain globular patterns. Path matching is case-insensitive. If case sensitivity is required, use a path_regexp matcher.
|
||||
By default, paths are treated as prefixes: a request matches if its path starts with the given path. There are two special exceptions to this:
|
||||
|
||||
- A path may start with `*`, then it is treated as a suffix match.
|
||||
- A path may start with `=`, then the path must match exactly what follows.
|
||||
|
||||
Paths may contain globular patterns. Path matching is case-insensitive. If case sensitivity is required, use a path_regexp matcher. There are two special cases:
|
||||
|
||||
##### http.matchers.path_regexp
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user