mirror of
https://github.com/adnanh/webhook.git
synced 2025-05-22 21:32:32 +00:00
match all hooks with the same id
This commit is contained in:
parent
4350685330
commit
f1ebc440a4
3 changed files with 82 additions and 48 deletions
17
hook/hook.go
17
hook/hook.go
|
@ -260,6 +260,23 @@ func (h *Hooks) Match(id string) *Hook {
|
|||
return nil
|
||||
}
|
||||
|
||||
// MatchAll iterates through Hooks and returns all of the hooks that match the
|
||||
// given ID, if no hook matches the given ID, nil is returned
|
||||
func (h *Hooks) MatchAll(id string) []*Hook {
|
||||
matchedHooks := make([]*Hook, 0)
|
||||
for i := range *h {
|
||||
if (*h)[i].ID == id {
|
||||
matchedHooks = append(matchedHooks, &(*h)[i])
|
||||
}
|
||||
}
|
||||
|
||||
if len(matchedHooks) > 0 {
|
||||
return matchedHooks
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Rules is a structure that contains one of the valid rule types
|
||||
type Rules struct {
|
||||
And *AndRule `json:"and"`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue