mirror of
https://github.com/caddyserver/website.git
synced 2025-04-21 20:46:15 -04:00
Improve matcher syntax docs, augment handle_path docs
This commit is contained in:
parent
dfd52789d9
commit
6400747447
2 changed files with 25 additions and 7 deletions
|
@ -2,9 +2,25 @@
|
|||
title: handle_path (Caddyfile directive)
|
||||
---
|
||||
|
||||
<script>
|
||||
window.$(function() {
|
||||
// Add a link to [<path_matcher>] as a special case for this directive.
|
||||
// The matcher text includes <> characters which are parsed as HTML,
|
||||
// so we must use text() to change the link text.
|
||||
window.$('pre.chroma .s:contains("<path_matcher>")')
|
||||
.map(function(k, item) {
|
||||
let text = item.innerText.replace(/</g, '<').replace(/>/g, '>');
|
||||
window.$(item)
|
||||
.html('<a href="/docs/caddyfile/matchers#path-matchers" style="color: inherit;" title="Matcher token">' + text + '</a>')
|
||||
.removeClass('s')
|
||||
.addClass('nd');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
# handle_path
|
||||
|
||||
Same as the [`handle` directive](/docs/caddyfile/directives/handle), but implicitly strips the matched path prefix.
|
||||
Works the same as the [`handle` directive](/docs/caddyfile/directives/handle), but implicitly uses [`uri strip_prefix`](/docs/caddyfile/directives/uri) to strip the matched path prefix.
|
||||
|
||||
Handling a request matching a certain path (while stripping that path from the request URI) is a common enough use case that it has its own directive for convenience.
|
||||
|
||||
|
@ -17,9 +33,9 @@ handle_path <path_matcher> {
|
|||
}
|
||||
```
|
||||
|
||||
- **<directives...>** is a list of HTTP handler directives or directive blocks, one per line, just like would be used outside of a handle_path block.
|
||||
- **<directives...>** is a list of HTTP handler directives or directive blocks, one per line, just like would be used outside of a `handle_path` block.
|
||||
|
||||
Note that only a single path matcher is accepted and required; you cannot use other kinds of matchers with handle_path.
|
||||
Only a single [path matcher](/docs/caddyfile/matchers#path-matchers) is accepted, and is required; you cannot use named matchers with `handle_path`.
|
||||
|
||||
## Examples
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue