commit
ae65bbf8e1
|
@ -28,3 +28,5 @@ key.pem
|
||||||
config.yaml
|
config.yaml
|
||||||
bin/*
|
bin/*
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
*.cert
|
||||||
|
*.key
|
||||||
|
|
|
@ -2,6 +2,9 @@ core:
|
||||||
port: "8088"
|
port: "8088"
|
||||||
notification_max: 100
|
notification_max: 100
|
||||||
production: true
|
production: true
|
||||||
|
ssl: false
|
||||||
|
cert_path: "cert.pem"
|
||||||
|
key_path: "key.pem"
|
||||||
|
|
||||||
api:
|
api:
|
||||||
push_uri: "/api/push"
|
push_uri: "/api/push"
|
||||||
|
|
|
@ -17,6 +17,9 @@ 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"`
|
Production bool `yaml:"production"`
|
||||||
|
SSL bool `yaml:"ssl"`
|
||||||
|
CertPath string `yaml:"cert_path"`
|
||||||
|
KeyPath string `yaml:"key_path"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SectionApi struct {
|
type SectionApi struct {
|
||||||
|
@ -43,6 +46,9 @@ func BuildDefaultPushConf() ConfYaml {
|
||||||
conf.Core.Port = "8088"
|
conf.Core.Port = "8088"
|
||||||
conf.Core.NotificationMax = 100
|
conf.Core.NotificationMax = 100
|
||||||
conf.Core.Production = true
|
conf.Core.Production = true
|
||||||
|
conf.Core.SSL = false
|
||||||
|
conf.Core.CertPath = "cert.pem"
|
||||||
|
conf.Core.KeyPath = "key.pem"
|
||||||
|
|
||||||
// Api
|
// Api
|
||||||
conf.Api.PushUri = "/api/push"
|
conf.Api.PushUri = "/api/push"
|
||||||
|
|
|
@ -2,7 +2,6 @@ package gopush
|
||||||
|
|
||||||
import (
|
import (
|
||||||
api "github.com/appleboy/gin-status-api"
|
api "github.com/appleboy/gin-status-api"
|
||||||
"github.com/braintree/manners"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -59,5 +58,9 @@ func GetMainEngine() *gin.Engine {
|
||||||
}
|
}
|
||||||
|
|
||||||
func RunHTTPServer() {
|
func RunHTTPServer() {
|
||||||
manners.ListenAndServe(":"+PushConf.Core.Port, GetMainEngine())
|
if PushConf.Core.SSL && PushConf.Core.CertPath != "" && PushConf.Core.KeyPath != "" {
|
||||||
|
GetMainEngine().RunTLS(":"+PushConf.Core.Port, PushConf.Core.CertPath, PushConf.Core.KeyPath)
|
||||||
|
} else {
|
||||||
|
GetMainEngine().Run(":" + PushConf.Core.Port)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue