fix #56 show server yml config file.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
@@ -29,9 +29,10 @@ type SectionCore struct {
|
||||
|
||||
// SectionAPI is sub seciont of config.
|
||||
type SectionAPI struct {
|
||||
PushURI string `yaml:"push_uri"`
|
||||
StatGoURI string `yaml:"stat_go_uri"`
|
||||
PushURI string `yaml:"push_uri"`
|
||||
StatGoURI string `yaml:"stat_go_uri"`
|
||||
StatAppURI string `yaml:"stat_app_uri"`
|
||||
ConfigURI string `yaml:"config_uri"`
|
||||
}
|
||||
|
||||
// SectionAndroid is sub seciont of config.
|
||||
@@ -75,6 +76,7 @@ func BuildDefaultPushConf() ConfYaml {
|
||||
conf.API.PushURI = "/api/push"
|
||||
conf.API.StatGoURI = "/api/stat/go"
|
||||
conf.API.StatAppURI = "/api/stat/app"
|
||||
conf.API.ConfigURI = "/api/config"
|
||||
|
||||
// Android
|
||||
conf.Android.Enabled = false
|
||||
|
||||
@@ -2,7 +2,7 @@ package gorush
|
||||
|
||||
const (
|
||||
// Version is gorush server version.
|
||||
Version = "1.0.0"
|
||||
Version = "1.1.0"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -55,6 +55,10 @@ func pushHandler(c *gin.Context) {
|
||||
})
|
||||
}
|
||||
|
||||
func configHandler(c *gin.Context) {
|
||||
c.YAML(http.StatusCreated, PushConf)
|
||||
}
|
||||
|
||||
func routerEngine() *gin.Engine {
|
||||
// set server mode
|
||||
gin.SetMode(PushConf.Core.Mode)
|
||||
@@ -69,6 +73,7 @@ func routerEngine() *gin.Engine {
|
||||
|
||||
r.GET(PushConf.API.StatGoURI, api.StatusHandler)
|
||||
r.GET(PushConf.API.StatAppURI, appStatusHandler)
|
||||
r.GET(PushConf.API.ConfigURI, configHandler)
|
||||
r.POST(PushConf.API.PushURI, pushHandler)
|
||||
r.GET("/", rootHandler)
|
||||
|
||||
|
||||
@@ -103,6 +103,17 @@ func TestAPIStatusAppHandler(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestAPIConfigHandler(t *testing.T) {
|
||||
initTest()
|
||||
|
||||
r := gofight.New()
|
||||
|
||||
r.GET("/api/config").
|
||||
Run(routerEngine(), func(r gofight.HTTPResponse, rq gofight.HTTPRequest) {
|
||||
assert.Equal(t, http.StatusCreated, r.Code)
|
||||
})
|
||||
}
|
||||
|
||||
func TestMissingNotificationsParameter(t *testing.T) {
|
||||
initTest()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user