go-common/app/job/main/workflow/http/http.go

38 lines
702 B
Go
Raw Normal View History

2019-04-22 10:49:16 +00:00
package http
import (
"go-common/app/job/main/workflow/conf"
"go-common/app/job/main/workflow/service"
"go-common/library/log"
bm "go-common/library/net/http/blademaster"
)
var (
svr *service.Service
)
func Init(c *conf.Config, s *service.Service) {
svr = s
// init local router
engine := bm.DefaultServer(c.HTTPServer)
route(engine)
// init local server
if err := engine.Start(); err != nil {
log.Error("bm.DefaultServer error(%v)", err)
panic(err)
}
}
// route .
func route(e *bm.Engine) {
e.Ping(ping)
}
// ping check server ok.
func ping(ctx *bm.Context) {
if err := svr.Ping(ctx); err != nil {
log.Error("workflow job ping error(%v)", err)
ctx.AbortWithStatus(503)
}
}