From 663be3c3591b6dc4cf905232691c661dd115063d Mon Sep 17 00:00:00 2001 From: Matt Holt Date: Mon, 20 Jun 2016 17:55:14 -0600 Subject: [PATCH] Couple typo fixes --- Converting-Add-ons-to-Plugins.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Converting-Add-ons-to-Plugins.md b/Converting-Add-ons-to-Plugins.md index 9c7ba61..53eb958 100644 --- a/Converting-Add-ons-to-Plugins.md +++ b/Converting-Add-ons-to-Plugins.md @@ -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