Updated Extending Caddy (markdown)

Kurt Jung 2019-09-08 16:32:06 -04:00
parent cf18fa41a7
commit 7c005f6ca8

@ -8,16 +8,16 @@ Some plug into Caddy core, while others plug into a specific server type. Some p
There are different kinds of plugins you can write:
- **[Server Types](https://github.com/mholt/caddy/wiki/Writing-a-Plugin:-Server-Type)** - A kind of server that Caddy can run (HTTP and DNS for example)
- **[Directives](https://github.com/mholt/caddy/wiki/Writing-a-Plugin:-Directives)** - A directive for the Caddyfile
- **[HTTP Middleware](https://github.com/mholt/caddy/wiki/Writing-a-Plugin:-HTTP-Middleware)** - A function that handles HTTP requests, usually invoked by a Caddyfile directive
- **[Caddyfile Loader](https://github.com/mholt/caddy/wiki/Writing-a-Plugin:-Caddyfile-Loader)** - Customize how the Caddyfile is loaded
- **[DNS Provider](https://github.com/mholt/caddy/wiki/Writing-a-Plugin:-DNS-Provider)** - Make ACME's DNS challenge compatible with your DNS provider
- **[Server Types](https://github.com/caddyserver/caddy/wiki/Writing-a-Plugin:-Server-Type)** - A kind of server that Caddy can run (HTTP and DNS for example)
- **[Directives](https://github.com/caddyserver/caddy/wiki/Writing-a-Plugin:-Directives)** - A directive for the Caddyfile
- **[HTTP Middleware](https://github.com/caddyserver/caddy/wiki/Writing-a-Plugin:-HTTP-Middleware)** - A function that handles HTTP requests, usually invoked by a Caddyfile directive
- **[Caddyfile Loader](https://github.com/caddyserver/caddy/wiki/Writing-a-Plugin:-Caddyfile-Loader)** - Customize how the Caddyfile is loaded
- **[DNS Provider](https://github.com/caddyserver/wiki/Writing-a-Plugin:-DNS-Provider)** - Make ACME's DNS challenge compatible with your DNS provider
- **Listener Middleware** - Wrap a net.Listener with your own Listener to do something at the transport or protocol layer
- **Event Hook** - Execute a function when the Caddy process emits certain events
- **[Cluster Support](https://github.com/mholt/caddy/wiki/Writing-a-Plugin:-Cluster-Support)** - Storage backends that enable sharing resources behind load balancers or in a cluster
- **[Cluster Support](https://github.com/caddyserver/caddy/wiki/Writing-a-Plugin:-Cluster-Support)** - Storage backends that enable sharing resources behind load balancers or in a cluster
The links above will show you how to write those kinds of plugins, but always refer to the [godoc](https://godoc.org/github.com/mholt/caddy) and the [code base itself](https://sourcegraph.com/github.com/mholt/caddy) when you have questions!
The links above will show you how to write those kinds of plugins, but always refer to the [godoc](https://godoc.org/github.com/caddyserver/caddy) and the [code base itself](https://sourcegraph.com/github.com/caddyserver/caddy) when you have questions!
## 5 Steps to Make a Caddy Plugin
@ -28,8 +28,8 @@ Even though there are different kinds of plugins, the process of creating one is
Start a new Go package with an init function and register your plugin with Caddy or the server type or the other plugin that uses it. The registration function you use depends on the kind of plugin. A few are shown here:
```go
import "github.com/mholt/caddy"
import "github.com/mholt/caddy/caddytls"
import "github.com/caddyserver/caddy"
import "github.com/caddyserver/caddy/caddytls"
func init() {
// register a "generic" plugin, like a directive or middleware
@ -60,7 +60,7 @@ Every plugin must have a name and, when applicable, the name must be unique for
### 2. Plug in your plugin.
To plug your plugin into Caddy, import it. This is usually done near the top of [run.go](https://github.com/mholt/caddy/blob/master/caddy/caddymain/run.go):
To plug your plugin into Caddy, import it. This is usually done near the top of [run.go](https://github.com/caddyserver/caddy/blob/master/caddy/caddymain/run.go):
```go
import _ "your/plugin/package/path/here"
@ -72,7 +72,7 @@ import _ "your/plugin/package/path/here"
### 4. Add your plugin to the Caddy web site.
Make it easy for others to find and use your plugin! [Follow these instructions](https://github.com/mholt/caddy/wiki/Publishing-a-Plugin-to-the-Download-Page) to add your plugin to Caddy's download page.
Make it easy for others to find and use your plugin! [Follow these instructions](https://github.com/caddyserver/caddy/wiki/Publishing-a-Plugin-to-the-Download-Page) to add your plugin to Caddy's download page.
### 5. Maintain your plugin.