Skip to content

Commit

Permalink
add RegisterOrUpdateEventHook() function
Browse files Browse the repository at this point in the history
  • Loading branch information
cbarbian-sap committed Aug 20, 2023
1 parent 4262f14 commit b2836ea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 0 additions & 1 deletion caddy.go
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,6 @@ func ConfigDigest(cdyfile Input) ([64]byte, error) {
if err != nil {
return [64]byte{}, err
}

sblocksJson, err := json.Marshal(sblocks)
if err != nil {
return [64]byte{}, err
Expand Down
9 changes: 9 additions & 0 deletions plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,15 @@ func RegisterEventHook(name string, hook EventHook) {
}
}

// RegisterOrUpdateEventHook plugs in hook. All the hooks should register themselves
// and they must have a name.
func RegisterOrUpdateEventHook(name string, hook EventHook) {
if name == "" {
panic("event hook must have a name")
}
eventHooks.Store(name, hook)
}

// EmitEvent executes the different hooks passing the EventType as an
// argument. This is a blocking function. Hook developers should
// use 'go' keyword if they don't want to block Caddy.
Expand Down

0 comments on commit b2836ea

Please sign in to comment.