mirror of
https://github.com/caddyserver/caddy.git
synced 2025-10-19 07:43:17 +00:00
events: Implement event system (#4912)
Co-authored-by: Matt Holt <mholt@users.noreply.github.com>
This commit is contained in:
parent
68d8ac9802
commit
d4d8bbcfc6
13 changed files with 569 additions and 34 deletions
|
@ -36,6 +36,7 @@ import (
|
|||
|
||||
"github.com/caddyserver/caddy/v2"
|
||||
"github.com/caddyserver/caddy/v2/caddyconfig/caddyfile"
|
||||
"github.com/caddyserver/caddy/v2/modules/caddyevents"
|
||||
"github.com/caddyserver/caddy/v2/modules/caddyhttp"
|
||||
"github.com/caddyserver/caddy/v2/modules/caddyhttp/headers"
|
||||
"github.com/caddyserver/caddy/v2/modules/caddyhttp/rewrite"
|
||||
|
@ -193,6 +194,7 @@ type Handler struct {
|
|||
|
||||
ctx caddy.Context
|
||||
logger *zap.Logger
|
||||
events *caddyevents.App
|
||||
}
|
||||
|
||||
// CaddyModule returns the Caddy module information.
|
||||
|
@ -205,6 +207,11 @@ func (Handler) CaddyModule() caddy.ModuleInfo {
|
|||
|
||||
// Provision ensures that h is set up properly before use.
|
||||
func (h *Handler) Provision(ctx caddy.Context) error {
|
||||
eventAppIface, err := ctx.App("events")
|
||||
if err != nil {
|
||||
return fmt.Errorf("getting events app: %v", err)
|
||||
}
|
||||
h.events = eventAppIface.(*caddyevents.App)
|
||||
h.ctx = ctx
|
||||
h.logger = ctx.Logger(h)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue