support gin production mode.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
59beeb7183
commit
9370c7f049
|
@ -1,17 +1,18 @@
|
||||||
core:
|
core:
|
||||||
port: "8088"
|
port: "8088"
|
||||||
notification_max: 100
|
notification_max: 100
|
||||||
|
production: true
|
||||||
|
|
||||||
api:
|
api:
|
||||||
push_uri: "/api/push"
|
push_uri: "/api/push"
|
||||||
stat_go_uri: "/api/status"
|
stat_go_uri: "/api/status"
|
||||||
|
|
||||||
android:
|
android:
|
||||||
enabled: true
|
enabled: false
|
||||||
apikey: ""
|
apikey: ""
|
||||||
|
|
||||||
ios:
|
ios:
|
||||||
enabled: true
|
enabled: false
|
||||||
pem_cert_path: "cert.pem"
|
pem_cert_path: "cert.pem"
|
||||||
pem_key_path: "key.pem"
|
pem_key_path: "key.pem"
|
||||||
production: false
|
production: false
|
||||||
|
|
|
@ -16,6 +16,7 @@ type ConfYaml struct {
|
||||||
type SectionCore struct {
|
type SectionCore struct {
|
||||||
Port string `yaml:"port"`
|
Port string `yaml:"port"`
|
||||||
NotificationMax int `yaml:"notification_max"`
|
NotificationMax int `yaml:"notification_max"`
|
||||||
|
Production bool `yaml:"production"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SectionApi struct {
|
type SectionApi struct {
|
||||||
|
@ -41,6 +42,7 @@ func BuildDefaultPushConf() ConfYaml {
|
||||||
// Core
|
// Core
|
||||||
conf.Core.Port = "8088"
|
conf.Core.Port = "8088"
|
||||||
conf.Core.NotificationMax = 100
|
conf.Core.NotificationMax = 100
|
||||||
|
conf.Core.Production = true
|
||||||
|
|
||||||
// Api
|
// Api
|
||||||
conf.Api.PushUri = "/api/push"
|
conf.Api.PushUri = "/api/push"
|
||||||
|
|
|
@ -40,6 +40,10 @@ func pushHandler(c *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetMainEngine() *gin.Engine {
|
func GetMainEngine() *gin.Engine {
|
||||||
|
if PushConf.Core.Production {
|
||||||
|
gin.SetMode(gin.ReleaseMode)
|
||||||
|
}
|
||||||
|
|
||||||
r := gin.New()
|
r := gin.New()
|
||||||
|
|
||||||
// Global middleware
|
// Global middleware
|
||||||
|
|
Loading…
Reference in New Issue