This commit is contained in:
a 2024-07-26 15:52:39 -05:00
parent b1cd29518f
commit 6897238d3b
No known key found for this signature in database
GPG key ID: 374BC539FE795AF0

View file

@ -86,7 +86,9 @@ Some users may immediately notice that this means it is impossible to use the `{
#### Parse the raw placeholder value in your unmarshaler #### Parse the raw placeholder value in your unmarshaler
Placeholders should be parsed as their raw values when parsing the Cazddyfile, just like any other string value. Placeholders are not evaluated at Caddyfile parse time, and should be preserved for later use. They are used as their raw string values.
In other words, parsing a placeholder is no different from parsing any other string.
```go ```go
func (g *Gizmo) UnmarshalCaddyfile(d *caddyfile.Dispenser) error { func (g *Gizmo) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
@ -98,7 +100,7 @@ func (g *Gizmo) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
} }
``` ```
#### Resolve the placeholder during Match or Serve #### Evaluate the placeholder during Match or Serve
In order to now correctly read our `g.Name` placeholder in a plugin matcher or middleware, we must extract the replacer from the context and use that replacer on our saved placeholder string. In order to now correctly read our `g.Name` placeholder in a plugin matcher or middleware, we must extract the replacer from the context and use that replacer on our saved placeholder string.