-
Notifications
You must be signed in to change notification settings - Fork 1
/
constants.go
65 lines (49 loc) · 1.8 KB
/
constants.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
package zoox
import (
"fmt"
"time"
"github.com/go-zoox/random"
)
// DefaultMiddlewares is the default global middleware
var DefaultMiddlewares = map[string]func(app *Application){
// Logger,
}
// DefaultMiddleware ...
func DefaultMiddleware(name string, fn func(app *Application)) {
DefaultMiddlewares[name] = fn
}
// DefaultGroupsFns ...
var DefaultGroupsFns = map[string]func(r *RouterGroup){}
// DefaultGroup ...
func DefaultGroup(prefix string, fn func(r *RouterGroup)) {
if _, ok := DefaultGroupsFns[prefix]; ok {
panic(fmt.Errorf("zoox: default group (%s) already registered", prefix))
}
DefaultGroupsFns[prefix] = fn
}
// DefaultSecretKey uses for session encryption and decryption.
var DefaultSecretKey = random.String(16)
// DefaultSessionMaxAge is the default session max age.
var DefaultSessionMaxAge = 1 * 24 * time.Hour
// BuiltInEnv is the built-in environment variable.
var (
BuiltInEnvPort = "PORT"
BuiltInEnvHTTPSPort = "HTTPS_PORT"
BuiltInEnvMode = "MODE"
BuiltInEnvLogLevel = "LOG_LEVEL"
BuiltInEnvSecretKey = "SECRET_KEY"
BuiltInEnvSessionMaxAge = "SESSION_MAX_AGE"
BuiltInEnvRedisHost = "REDIS_HOST"
BuiltInEnvRedisPort = "REDIS_PORT"
BuiltInEnvRedisUser = "REDIS_USER"
BuiltInEnvRedisPass = "REDIS_PASS"
BuiltInEnvRedisDB = "REDIS_DB"
BuiltInEnvMonitorPrometheusEnabled = "MONITOR_PROMETHEUS_ENABLED"
BuiltInEnvMonitorPrometheusPath = "MONITOR_PROMETHEUS_PATH"
BuiltInEnvMonitorSentryEnabled = "MONITOR_SENTRY_ENABLED"
BuiltInEnvMonitorSentryDSN = "MONITOR_SENTRY_DSN"
BuiltInEnvMonitorSentryDebug = "MONITOR_SENTRY_DEBUG"
BuiltInEnvMonitorSentryRepanic = "MONITOR_SENTRY_REPANIC"
BuiltInEnvMonitorSentryWaitForDelivery = "MONITOR_SENTRY_WAIT_FOR_DELIVERY"
BuiltInEnvMonitorSentryTimeout = "MONITOR_SENTRY_TIMEOUT"
)