forked from nyaruka/goflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
resthook.go
39 lines (32 loc) · 966 Bytes
/
resthook.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package flows
import (
"github.com/nyaruka/goflow/assets"
)
// Resthook represents a named event and a set of subscribers
type Resthook struct {
assets.Resthook
}
// NewResthook returns a new resthook object
func NewResthook(asset assets.Resthook) *Resthook {
return &Resthook{Resthook: asset}
}
// Asset returns the underlying asset
func (r *Resthook) Asset() assets.Resthook { return r.Resthook }
// ResthookAssets provides access to all resthook assets
type ResthookAssets struct {
bySlug map[string]*Resthook
}
// NewResthookAssets creates a new set of resthook assets
func NewResthookAssets(resthooks []assets.Resthook) *ResthookAssets {
s := &ResthookAssets{
bySlug: make(map[string]*Resthook, len(resthooks)),
}
for _, asset := range resthooks {
s.bySlug[asset.Slug()] = NewResthook(asset)
}
return s
}
// FindBySlug finds the group with the given UUID
func (s *ResthookAssets) FindBySlug(slug string) *Resthook {
return s.bySlug[slug]
}