35 lines
698 B
Go
35 lines
698 B
Go
|
package permission
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
|
||
|
"github.com/infraboard/mcube/v2/ioc"
|
||
|
"github.com/infraboard/mcube/v2/ioc/config/gorestful"
|
||
|
"github.com/infraboard/modules/iam/apps/endpoint"
|
||
|
)
|
||
|
|
||
|
func init() {
|
||
|
ioc.Api().Registry(&ApiRegister{})
|
||
|
}
|
||
|
|
||
|
type ApiRegister struct {
|
||
|
ioc.ObjectImpl
|
||
|
endpoint endpoint.Service
|
||
|
}
|
||
|
|
||
|
func (a *ApiRegister) Init() error {
|
||
|
// 注册认证中间件
|
||
|
entries := endpoint.NewEntryFromRestfulContainer(gorestful.RootRouter())
|
||
|
req := endpoint.NewRegistryEndpointRequest()
|
||
|
req.AddItem(entries...)
|
||
|
_, err := a.endpoint.RegistryEndpoint(context.Background(), req)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
func (c *ApiRegister) Name() string {
|
||
|
return "api_register"
|
||
|
}
|