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