docs: A few minor changes

This commit is contained in:
Matthew Holt 2020-06-08 16:32:57 -06:00
parent db18a5d4c8
commit 9daa0fa331
No known key found for this signature in database
GPG key ID: 2A349DD577D586A5
3 changed files with 18 additions and 3 deletions

View file

@ -11,10 +11,11 @@ This directive is a special case: it is evaluated before the structure is parsed
## Syntax
```caddy-d
import <pattern>
import <pattern> [<args...>]
```
- **&lt;pattern&gt;** is the filename, glob pattern, or name of [snippet](/docs/caddyfile/concepts#snippets) to include. Its contents will replace this line as if that file's contents appeared here to begin with. It is an error if a specific file cannot be found, but an empty glob pattern is not an error.
- **&lt;args...&gt;** is an optional list of arguments to pass to the imported tokens. They can be used with a placeholder of the form `{args.N}` where `N` is the 0-based positional index of the parameter. This placeholder is a special case and is evaluated at parse-time, not run-time.
## Examples
@ -24,3 +25,17 @@ Import all files in an adjacent sites-enabled folder:
```caddy-d
import sites-enabled/*
```
Import a snippet that sets CORS headers using an import argument:
```caddy
(cors) {
@origin header Origin {args.0}
header @origin Access-Control-Allow-Origin "{args.0}"
header @origin Access-Control-Request-Method GET
}
example.com {
import cors example.com
}
```