Updated Writing a Plugin: Server Type (markdown)

Matt Holt 2016-07-18 16:41:58 -06:00
parent 65fb915f42
commit b1ac327cc7

@ -57,7 +57,7 @@ Ultimately, your goal is to make it so that `MakeServers()` returns a list of [c
For example: the HTTP server [uses its context type](https://github.com/mholt/caddy/blob/aede4ccbce94bcb67161674e30dd1bfa7296448c/caddyhttp/httpserver/plugin.go#L54-L63) to keep a map of site configs. The package also has an exported function, `GetConfig(c Controller)` that gets a config for a certain site, designated by the [caddy.Controller](https://godoc.org/github.com/mholt/caddy#Controller) that is passed in. The config, in turn, stores the list of middleware, etc -- all the information needed to set up a site. Each directive's action calls the GetConfig function so they can help set up the site properly. By the time `MakeServers()` is called, all it has to do is combine those site configs into server instances and return them. (Server instances implement [caddy.Server](https://godoc.org/github.com/mholt/caddy#Server).)
## Server
### Server
The `caddy.Server` interface considers both TCP and non-TCP servers. It has four methods; two are for TCP, two are for UDP or other: