Skip to content

Commit b2836ea

Browse files
committed
add RegisterOrUpdateEventHook() function
1 parent 4262f14 commit b2836ea

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

caddy.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,6 @@ func ConfigDigest(cdyfile Input) ([64]byte, error) {
10481048
if err != nil {
10491049
return [64]byte{}, err
10501050
}
1051-
10521051
sblocksJson, err := json.Marshal(sblocks)
10531052
if err != nil {
10541053
return [64]byte{}, err

plugins.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,15 @@ func RegisterEventHook(name string, hook EventHook) {
271271
}
272272
}
273273

274+
// RegisterOrUpdateEventHook plugs in hook. All the hooks should register themselves
275+
// and they must have a name.
276+
func RegisterOrUpdateEventHook(name string, hook EventHook) {
277+
if name == "" {
278+
panic("event hook must have a name")
279+
}
280+
eventHooks.Store(name, hook)
281+
}
282+
274283
// EmitEvent executes the different hooks passing the EventType as an
275284
// argument. This is a blocking function. Hook developers should
276285
// use 'go' keyword if they don't want to block Caddy.

0 commit comments

Comments
 (0)