github.com/infraboard/keyauth@v0.8.1/apps/application/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/application" 8 ) 9 10 var ( 11 api = &handler{} 12 ) 13 14 type handler struct { 15 service application.ServiceServer 16 } 17 18 // Registry 注册HTTP服务路由 19 func (h *handler) Registry(router router.SubRouter) { 20 r := router.ResourceRouter("application") 21 r.BasePath("applications") 22 r.Handle("POST", "/", h.CreateApplication) 23 r.Handle("GET", "/", h.QueryApplication) 24 r.Handle("GET", "/:id", h.GetApplication) 25 r.Handle("DELETE", "/:id", h.DestroyApplication) 26 } 27 28 func (h *handler) Config() error { 29 h.service = app.GetGrpcApp(application.AppName).(application.ServiceServer) 30 return nil 31 } 32 33 func (h *handler) Name() string { 34 return application.AppName 35 } 36 37 func init() { 38 app.RegistryHttpApp(api) 39 }