35 lines
698 B
Go
Raw Normal View History

2025-03-16 15:26:12 +08:00
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"
}