go-common/app/job/main/passport-game-local/http/http.go

37 lines
697 B
Go
Raw Normal View History

2019-04-22 10:49:16 +00:00
package http
import (
"go-common/app/job/main/passport-game-local/conf"
"go-common/app/job/main/passport-game-local/service"
"go-common/library/log"
bm "go-common/library/net/http/blademaster"
)
var (
srv *service.Service
)
// Init init http sever instance.
func Init(c *conf.Config, s *service.Service) {
srv = s
// init inner router
eng := bm.DefaultServer(c.BM)
initRouter(eng)
// init inner server
if err := eng.Start(); err != nil {
log.Error("bm.DefaultServer error(%v)", err)
panic(err)
}
}
// initRouter init inner router.
func initRouter(e *bm.Engine) {
// health check
e.Ping(ping)
}
// ping check server ok.
func ping(c *bm.Context) {
c.JSON(nil, srv.Ping(c))
}