@@ -1,7 +1,7 @@
|
||||
core:
|
||||
port: "8088"
|
||||
notification_max: 100
|
||||
production: true
|
||||
mode: "release"
|
||||
ssl: false
|
||||
cert_path: "cert.pem"
|
||||
key_path: "key.pem"
|
||||
|
||||
@@ -16,7 +16,7 @@ type ConfYaml struct {
|
||||
type SectionCore struct {
|
||||
Port string `yaml:"port"`
|
||||
NotificationMax int `yaml:"notification_max"`
|
||||
Production bool `yaml:"production"`
|
||||
Mode string `yaml:"mode"`
|
||||
SSL bool `yaml:"ssl"`
|
||||
CertPath string `yaml:"cert_path"`
|
||||
KeyPath string `yaml:"key_path"`
|
||||
@@ -45,7 +45,7 @@ func BuildDefaultPushConf() ConfYaml {
|
||||
// Core
|
||||
conf.Core.Port = "8088"
|
||||
conf.Core.NotificationMax = 100
|
||||
conf.Core.Production = true
|
||||
conf.Core.Mode = "release"
|
||||
conf.Core.SSL = false
|
||||
conf.Core.CertPath = "cert.pem"
|
||||
conf.Core.KeyPath = "key.pem"
|
||||
|
||||
@@ -39,9 +39,8 @@ func pushHandler(c *gin.Context) {
|
||||
}
|
||||
|
||||
func GetMainEngine() *gin.Engine {
|
||||
if PushConf.Core.Production {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
}
|
||||
// set server mode
|
||||
gin.SetMode(PushConf.Core.Mode)
|
||||
|
||||
r := gin.New()
|
||||
|
||||
|
||||
@@ -3,18 +3,17 @@ package gopush
|
||||
import (
|
||||
"github.com/appleboy/gofight"
|
||||
"github.com/buger/jsonparser"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func initTest() {
|
||||
gin.SetMode(gin.TestMode)
|
||||
PushConf = BuildDefaultPushConf()
|
||||
PushConf.Core.Mode = "test"
|
||||
}
|
||||
|
||||
func TestGinHelloWorld(t *testing.T) {
|
||||
func TestRootHandler(t *testing.T) {
|
||||
initTest()
|
||||
|
||||
r := gofight.New()
|
||||
|
||||
Reference in New Issue
Block a user