-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.go
51 lines (43 loc) · 1.21 KB
/
options.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
40
41
42
43
44
45
46
47
48
49
50
51
package gometawebhooks
// Option is a configuration option for the webhook
type Option func(*Webhooks) error
// Options is a namespace var for configuration options
var Options = MetaWebhookOptions{}
// MetaWebhookOptions is a namespace for configuration option methods
type MetaWebhookOptions struct{}
// Sets the Facebook APP Secret
func (MetaWebhookOptions) Secret(secret string) Option {
return func(hooks *Webhooks) error {
hooks.secret = secret
return nil
}
}
// Sets the Facebook APP webhook subscription verify token
func (MetaWebhookOptions) Token(token string) Option {
return func(hooks *Webhooks) error {
hooks.token = token
return nil
}
}
func (MetaWebhookOptions) IgnoreEchoMessages(ignore bool) Option {
return func(hooks *Webhooks) error {
hooks.ignoreEchoMessages = ignore
return nil
}
}
// Ensures embedded JSON schema is compiled
func (MetaWebhookOptions) CompileSchema() Option {
return func(hooks *Webhooks) error {
if err := hooks.compileSchema(); err != nil {
return err
}
return nil
}
}
// Sets a custom header signature name
func (MetaWebhookOptions) CustomHeaderSigName(name string) Option {
return func(hooks *Webhooks) error {
hooks.headerSigName = name
return nil
}
}