Updated Writing a Plugin: Directives (markdown)

Matt Holt 2016-09-19 17:44:12 -06:00
parent e916b69d8c
commit 1127a3b64d

@ -7,6 +7,7 @@ Directives can do things like run code when the server starts or shuts down, cha
1. Create a new Go package 1. Create a new Go package
2. Implement a Setup Function 2. Implement a Setup Function
3. Order your Directive 3. Order your Directive
4. Plug in your Plugin (applies to any plugin)
## 1. Create a new Go package ## 1. Create a new Go package
@ -80,6 +81,8 @@ The last thing you have to do is tell the server type where in the process to ex
Each server type has a list of strings where each item is the name of a directive. For instance, see [the HTTP server's list](https://github.com/mholt/caddy/blob/d3860f95f59b5f18e14ddf3d67b4c44dbbfdb847/caddyhttp/httpserver/plugin.go#L314-L355) of supported directives. Add your directive to the list in the proper place. Each server type has a list of strings where each item is the name of a directive. For instance, see [the HTTP server's list](https://github.com/mholt/caddy/blob/d3860f95f59b5f18e14ddf3d67b4c44dbbfdb847/caddyhttp/httpserver/plugin.go#L314-L355) of supported directives. Add your directive to the list in the proper place.
## 4. Plug in your Plugin
Finally, don't forget to import your plugin's package! Caddy must import your plugin to register and execute it. This is usually done within [run.go](https://github.com/mholt/caddy/blob/master/caddy/caddymain/run.go): Finally, don't forget to import your plugin's package! Caddy must import your plugin to register and execute it. This is usually done within [run.go](https://github.com/mholt/caddy/blob/master/caddy/caddymain/run.go):
```go ```go