fix #56 show server yml config file.

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu
2016-04-15 15:05:23 +08:00
parent 880d34d213
commit 158ab729d2
6 changed files with 25 additions and 3 deletions

View File

@@ -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

View File

@@ -2,7 +2,7 @@ package gorush
const (
// Version is gorush server version.
Version = "1.0.0"
Version = "1.1.0"
)
const (

View File

@@ -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)

View File

@@ -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()