github.com/infraboard/keyauth@v0.8.1/apps/verifycode/http/http.go (about) 1 package http 2 3 import ( 4 "github.com/infraboard/mcube/app" 5 "github.com/infraboard/mcube/http/router" 6 7 "github.com/infraboard/keyauth/apps/verifycode" 8 ) 9 10 var ( 11 api = &handler{} 12 ) 13 14 type handler struct { 15 service verifycode.ServiceServer 16 } 17 18 // Registry 注册HTTP服务路由 19 func (h *handler) Registry(router router.SubRouter) { 20 r := router.ResourceRouter("verify_code") 21 22 r.BasePath("verify_code") 23 r.Handle("POST", "/pass", h.IssueCodeByPass) 24 r.Handle("POST", "/token", h.IssueCodeByToken) 25 } 26 27 func (h *handler) Config() error { 28 h.service = app.GetGrpcApp(verifycode.AppName).(verifycode.ServiceServer) 29 return nil 30 } 31 32 func (h *handler) Name() string { 33 return verifycode.AppName 34 } 35 36 func init() { 37 app.RegistryHttpApp(api) 38 }