-
-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: More changes for upcoming v2.5.0 release (#226)
- Loading branch information
1 parent
35a02d7
commit eaf0aae
Showing
6 changed files
with
73 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
--- | ||
title: vars (Caddyfile directive) | ||
--- | ||
|
||
# vars | ||
|
||
Sets one or more variables to a particular value, to be used later in the request handling chain. | ||
|
||
The primary way to access variables is with placeholders, which have the form `{vars.variable_name}`, or with the [`vars`](/docs/caddyfile/matchers#vars) and [`vars_regexp`](/docs/caddyfile/matchers#vars_regexp) request matchers. | ||
|
||
## Syntax | ||
|
||
```caddy-d | ||
vars [<matcher>] [<name> <value>] { | ||
<name> <value> | ||
... | ||
} | ||
``` | ||
|
||
- **<name>** is the variable name to set. | ||
|
||
- **<value>** is the value of the variable. | ||
|
||
The value will be type converted if possible; `true` and `false` will be converted to boolean types, and numeric values will be converted to integer or float accordingly. To avoid this conversion, you may wrap the output with [quotes](/docs/caddyfile/concepts#tokens-and-quotes) and they will stay strings. | ||
|
||
## Examples | ||
|
||
To set a single variable, the value being conditional based on the request path, then responding with the value: | ||
|
||
```caddy-d | ||
vars /foo* isFoo "yep" | ||
vars isFoo "nope" | ||
respond {vars.isFoo} | ||
``` | ||
|
||
To set multiple variables, each converted to the appropriate scalar type: | ||
|
||
```caddy-d | ||
vars { | ||
# boolean | ||
abc true | ||
# integer | ||
def 1 | ||
# float | ||
ghi 2.3 | ||
# string | ||
jkl "example" | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters