mirror of
https://github.com/caddyserver/caddy.git
synced 2025-05-23 11:00:00 +08:00
Refactor Caddyfile adapter and module registration
Use piles from which to draw config values. Module values can return their name, so now we can do two-way mapping from value to name and name to value; whereas before we could only map name to value. This was problematic with the Caddyfile adapter since it receives values and needs to know the name to put in the config.
This commit is contained in:
@ -23,10 +23,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
caddy.RegisterModule(caddy.Module{
|
||||
Name: "http.handlers.headers",
|
||||
New: func() interface{} { return new(Headers) },
|
||||
})
|
||||
caddy.RegisterModule(Headers{})
|
||||
}
|
||||
|
||||
// Headers is a middleware which can mutate HTTP headers.
|
||||
@ -35,6 +32,14 @@ type Headers struct {
|
||||
Response *RespHeaderOps `json:"response,omitempty"`
|
||||
}
|
||||
|
||||
// CaddyModule returns the Caddy module information.
|
||||
func (Headers) CaddyModule() caddy.ModuleInfo {
|
||||
return caddy.ModuleInfo{
|
||||
Name: "http.handlers.headers",
|
||||
New: func() caddy.Module { return new(Headers) },
|
||||
}
|
||||
}
|
||||
|
||||
// HeaderOps defines some operations to
|
||||
// perform on HTTP headers.
|
||||
type HeaderOps struct {
|
||||
|
Reference in New Issue
Block a user