-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathserver.go
More file actions
37 lines (30 loc) · 781 Bytes
/
server.go
File metadata and controls
37 lines (30 loc) · 781 Bytes
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
package serveropts
import (
"github.com/theopenlane/riverboat/config"
serverconfig "github.com/theopenlane/riverboat/internal/server/config"
)
type ServerOptions struct {
ConfigProvider serverconfig.Provider
Config serverconfig.Config
}
func NewServerOptions(opts []ServerOption, cfgLoc string) *ServerOptions {
// load koanf config
c, err := config.Load(&cfgLoc)
if err != nil {
panic(err)
}
so := &ServerOptions{
Config: serverconfig.Config{
Settings: *c,
},
}
for _, opt := range opts {
opt.apply(so)
}
return so
}
// AddServerOptions applies a server option after the initial setup
// this should be used when information is not available on NewServerOptions
func (so *ServerOptions) AddServerOptions(opt ServerOption) {
opt.apply(so)
}