Skip to content

Commit 3900e91

Browse files
authored
Update import.md (#440)
See details here: caddyserver/caddy#6130 (comment)
1 parent f3b6d18 commit 3900e91

File tree

1 file changed

+38
-10
lines changed
  • src/docs/markdown/caddyfile/directives

1 file changed

+38
-10
lines changed

src/docs/markdown/caddyfile/directives/import.md

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import <pattern> [<args...>] [{block}]
3737
⚠️ <i>Experimental</i> <span style='white-space: pre;'> | </span> <span>v2.9.x+</span>
3838
- **{block...}** is an optional block to pass to the imported tokens. This placeholder is a special case, and is evaluated recursively at Caddyfile-parse-time, not at runtime. They can be used in two forms:
3939
- `{block}` where the content of provided block will be substituted for the placeholder.
40-
- `{block.key}` where `key` is the first token of a parameter within the provided block
40+
- `{blocks.key}` where `key` is the first token of a parameter within the provided block
4141

4242

4343
## Examples
@@ -94,34 +94,62 @@ example.com {
9494

9595
⚠️ <i>Experimental</i> <span style='white-space: pre;'> | </span> <span>v2.9.x+</span>
9696

97-
Import a snippet which provides extendable options for a reverse proxy
97+
Import a snippet which responds with a configurable "hello world" message and content-type:
98+
99+
```caddy
100+
(hello-world) {
101+
header {
102+
Cache-Control max-age=3600
103+
X-Foo bar
104+
{blocks.content_type}
105+
}
106+
respond /hello-world 200 {
107+
{blocks.body}
108+
}
109+
}
110+
111+
example.com {
112+
import hello-world {
113+
content_type {
114+
Content-Type text/html
115+
}
116+
body {
117+
body "<h1>hello world</h1>"
118+
}
119+
}
120+
}
121+
```
122+
123+
Import a snippet which provides extendable options for a reverse proxy:
98124

99125
```caddy
100126
(extendable-proxy) {
101127
reverse_proxy {
102-
to {block.proxy_target}
128+
{block.proxy_target}
103129
{block.proxy_options}
104130
}
105131
}
106132
107133
example.com {
108134
import extendable-proxy {
109-
proxy_target 10.0.0.1
110-
proxy_options {
111-
transport http {
112-
tls
135+
proxy_target {
136+
to 10.0.0.1
137+
}
138+
proxy_options {
139+
transport http {
140+
tls
141+
}
113142
}
114-
}
115143
}
116144
}
117145
```
118146

119-
Import a snippet that serves any set of directives, but with a pre-loaded middleware.
147+
Import a snippet that serves any set of directives, but with a pre-loaded middleware:
120148

121149
```caddy
122150
(instrumented-route) {
123151
header {
124-
Alt-Svc `h3="0.0.0.0:443"; ma=2592000`
152+
Alt-Svc `h3="0.0.0.0:443"; ma=2592000`
125153
}
126154
tracing {
127155
span args[0]

0 commit comments

Comments
 (0)