-
Notifications
You must be signed in to change notification settings - Fork 4
/
options.go
45 lines (37 loc) · 976 Bytes
/
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
package faucet
import (
"log/slog"
"github.com/gnolang/faucet/config"
)
type Option func(f *Faucet)
// WithLogger specifies the logger for the faucet
func WithLogger(l *slog.Logger) Option {
return func(f *Faucet) {
f.logger = l
}
}
// WithConfig specifies the config for the faucet
func WithConfig(c *config.Config) Option {
return func(f *Faucet) {
f.config = c
}
}
// WithMiddlewares specifies the request middlewares for the faucet
func WithMiddlewares(middlewares []Middleware) Option {
return func(f *Faucet) {
f.middlewares = middlewares
}
}
// WithHandlers specifies the HTTP handlers for the faucet
func WithHandlers(handlers []Handler) Option {
return func(f *Faucet) {
f.handlers = append(f.handlers, handlers...)
}
}
// WithPrepareTxMessageFn specifies the faucet
// transaction message constructor
func WithPrepareTxMessageFn(prepareTxMsgFn PrepareTxMessageFn) Option {
return func(f *Faucet) {
f.prepareTxMsgFn = prepareTxMsgFn
}
}