more explained

This commit is contained in:
a 2024-07-25 16:18:34 -05:00
parent d5429515d3
commit b1cd29518f
No known key found for this signature in database
GPG key ID: 374BC539FE795AF0

View file

@ -100,7 +100,9 @@ func (g *Gizmo) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
#### Resolve the placeholder during Match or Serve #### Resolve 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.
This gives us a string with all valid replacements done, which we can then use in whichever way we want. In the example, we write those bytes to output
```go ```go
func (g *Gizmo) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error { func (g *Gizmo) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error {