-
-
Notifications
You must be signed in to change notification settings - Fork 171
/
api.go
143 lines (125 loc) · 3.83 KB
/
api.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
package serv
import (
"time"
"github.com/dosco/graphjin/core"
"github.com/dosco/graphjin/internal/serv/internal/auth"
"github.com/spf13/viper"
)
const (
LogLevelNone int = iota
LogLevelInfo
LogLevelWarn
LogLevelError
LogLevelDebug
)
type Core = core.Config
// Config struct holds the GraphJin config values
type Config struct {
Core `mapstructure:",squash"`
Serv `mapstructure:",squash"`
closeFn func()
hostPort string
cpath string
vi *viper.Viper
}
// Serv struct contains config values used by the GraphJin service
type Serv struct {
AppName string `mapstructure:"app_name"`
Production bool
LogLevel string `mapstructure:"log_level"`
LogFormat string `mapstructure:"log_format"`
HostPort string `mapstructure:"host_port"`
Host string
Port string
HTTPGZip bool `mapstructure:"http_compress"`
WebUI bool `mapstructure:"web_ui"`
EnableTracing bool `mapstructure:"enable_tracing"`
WatchAndReload bool `mapstructure:"reload_on_config_change"`
AuthFailBlock bool `mapstructure:"auth_fail_block"`
SeedFile string `mapstructure:"seed_file"`
MigrationsPath string `mapstructure:"migrations_path"`
AllowedOrigins []string `mapstructure:"cors_allowed_origins"`
AllowedHeaders []string `mapstructure:"cors_allowed_headers"`
DebugCORS bool `mapstructure:"cors_debug"`
APIPath string `mapstructure:"api_path"`
CacheControl string `mapstructure:"cache_control"`
// Telemetry struct contains OpenCensus metrics and tracing related config
Telemetry struct {
Debug bool
Interval *time.Duration
Metrics struct {
Exporter string
Endpoint string
Namespace string
Key string
}
Tracing struct {
Exporter string
Endpoint string
Sample string
IncludeQuery bool `mapstructure:"include_query"`
IncludeParams bool `mapstructure:"include_params"`
}
}
Auth auth.Auth
Auths []auth.Auth
// DB struct contains db config
DB struct {
Type string
Host string
Port uint16
DBName string
User string
Password string
Schema string
PoolSize int32 `mapstructure:"pool_size"`
MaxRetries int `mapstructure:"max_retries"`
PingTimeout time.Duration `mapstructure:"ping_timeout"`
EnableTLS bool `mapstructure:"enable_tls"`
ServerName string `mapstructure:"server_name"`
ServerCert string `mapstructure:"server_cert"`
ClientCert string `mapstructure:"client_cert"`
ClientKey string `mapstructure:"client_key"`
} `mapstructure:"database"`
Actions []Action
RateLimiter struct {
Rate float64
Bucket int
IPHeader string `mapstructure:"ip_header"`
} `mapstructure:"rate_limiter"`
}
// // Auth struct contains authentication related config values used by the GraphJin service
// type Auth struct {
// Name string
// Type string
// Cookie string
// CredsInHeader bool `mapstructure:"creds_in_header"`
// Rails struct {
// Version string
// SecretKeyBase string `mapstructure:"secret_key_base"`
// URL string
// Password string
// MaxIdle int `mapstructure:"max_idle"`
// MaxActive int `mapstructure:"max_active"`
// Salt string
// SignSalt string `mapstructure:"sign_salt"`
// AuthSalt string `mapstructure:"auth_salt"`
// }
// JWT struct {
// Provider string
// Secret string
// PubKeyFile string `mapstructure:"public_key_file"`
// PubKeyType string `mapstructure:"public_key_type"`
// }
// Header struct {
// Name string
// Value string
// Exists bool
// }
// }
// Action struct contains config values for a GraphJin service action
type Action struct {
Name string
SQL string
AuthName string `mapstructure:"auth_name"`
}