github.com/infraboard/keyauth@v0.8.1/apps/wxwork/http/http.go (about) 1 package http 2 3 import ( 4 "github.com/infraboard/keyauth/apps/wxwork" 5 "github.com/infraboard/mcube/app" 6 "github.com/infraboard/mcube/http/label" 7 "github.com/infraboard/mcube/http/router" 8 ) 9 10 var ( 11 api = &handler{} 12 ) 13 14 type handler struct { 15 service wxwork.WechatWork 16 } 17 18 // Registry 注册HTTP服务路由 19 func (h *handler) Registry(router router.SubRouter) { 20 wx := router.ResourceRouter("wechat") 21 wx.BasePath("settings/wechat") 22 wx.Permission(true) 23 wx.Handle("GET", "/", h.GetConf).AddLabel(label.Get) 24 wx.Handle("GET", "/list", h.ListConf).AddLabel(label.List) 25 wx.Handle("POST", "/", h.CreateConf).AddLabel(label.Create) 26 wx.Handle("DELETE", "/", h.DestroyConfig).AddLabel(label.Create) 27 wx.Handle("GET", "/callback", h.WechatWorkCheck).AddLabel(label.Create).DisableAuth() 28 } 29 30 func (h *handler) Config() error { 31 h.service = app.GetInternalApp(wxwork.AppName).(wxwork.WechatWork) 32 return nil 33 } 34 35 func (h *handler) Name() string { 36 return wxwork.AppName 37 } 38 39 func init() { 40 app.RegistryHttpApp(api) 41 }