mirror of
https://github.com/caddyserver/caddy.git
synced 2025-07-09 03:04:57 -04:00
Couple typo fixes
parent
b460fd2248
commit
663be3c359
@ -80,17 +80,17 @@ siteConfig.AddMiddleware(func(next httpserver.Handler) httpserver.Handler {
|
||||
Instead of calling `setup.NewTestController()` like you did before, call `caddy.NewTestController()`:
|
||||
|
||||
```go
|
||||
c := caddy.NewTestController(input)
|
||||
c := caddy.NewTestController("http", input)
|
||||
```
|
||||
|
||||
To test that the middleware was set up properly, you'll need to get the config it was added to. The test controller uses an empty string key:
|
||||
|
||||
```go
|
||||
cfg := httpserver.GetConfig("")
|
||||
cfg := httpserver.GetConfig(c)
|
||||
mids := cfg.Middleware() // []httpserver.Middleware
|
||||
```
|
||||
|
||||
From there, you'll usually want the last middleware in the list, `mids[len(mids)-1]`. If you're not in a loop you can just assume `mids[0]`. Of course, if you didn't add any middleware, you can omit these checks.
|
||||
From there, you'll usually want the last middleware in the list, `mids[len(mids)-1]`. If you're not in a loop or you created a new controller each time, you can just assume `mids[0]`. Of course, if you didn't add any middleware, you can omit these checks.
|
||||
|
||||
## 4. Register plugin
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user