-
Notifications
You must be signed in to change notification settings - Fork 14
/
library.go
53 lines (42 loc) · 1.68 KB
/
library.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
52
53
package config
import (
"time"
"github.com/anz-bank/sysl-go/log"
"github.com/anz-bank/sysl-go/jwtauth"
"github.com/anz-bank/sysl-go/validator"
)
// LibraryConfig struct.
type LibraryConfig struct {
Log LogConfig `yaml:"log" mapstructure:"log"`
Profiling bool `yaml:"profiling" mapstructure:"profiling"`
Health bool `yaml:"health" mapstructure:"health"`
Authentication *AuthenticationConfig `yaml:"authentication" mapstructure:"authentication"`
Trace TraceConfig `yaml:"trace" mapstructure:"trace"`
}
type AdminConfig struct {
ContextTimeout time.Duration `yaml:"contextTimeout" mapstructure:"contextTimeout" validate:"nonnil"`
HTTP CommonHTTPServerConfig `yaml:"http" mapstructure:"http"`
}
// LogConfig struct.
type LogConfig struct {
Format string `yaml:"format" mapstructure:"format" validate:"nonnil,oneof=color json text"` // Deprecated: Use Hooks#Logger
Level log.Level `yaml:"level" mapstructure:"level" validate:"nonnil"`
ReportCaller bool `yaml:"caller" mapstructure:"caller"` // Deprecated: Use Hooks#Logger
// LogPayload logs the contents of request and response objects.
LogPayload bool `yaml:"logPayload" mapstructure:"logPayload"`
}
// AuthenticationConfig struct.
type AuthenticationConfig struct {
JWTAuth *jwtauth.Config `yaml:"jwtauth" mapstructure:"jwtauth"`
}
// TraceConfig struct.
type TraceConfig struct {
IncomingHeaderForID string `yaml:"incomingHeaderForID" mapstructure:"incomingHeaderForID"`
}
func (c *LibraryConfig) Validate() error {
// existing validation
if err := validator.Validate(c); err != nil {
return err
}
return nil
}