1 Star 0 Fork 0

Wshile / keyauth

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
http.go 1003 Bytes
一键复制 编辑 原始数据 按行查看 历史
wangshile 提交于 2023-05-16 10:50 . 添加角色校验
package api
import (
"gitee.com/wshile/keyauth/apps/policy"
restfulspec "github.com/emicklei/go-restful-openapi"
"github.com/emicklei/go-restful/v3"
"github.com/infraboard/mcube/app"
"github.com/infraboard/mcube/http/response"
"github.com/infraboard/mcube/logger"
"github.com/infraboard/mcube/logger/zap"
)
var (
h = &handler{}
)
type handler struct {
service policy.Service
log logger.Logger
}
func (h *handler) Config() error {
h.log = zap.L().Named(policy.AppName)
h.service = app.GetGrpcApp(policy.AppName).(policy.Service)
return nil
}
func (h *handler) Name() string {
return policy.AppName
}
func (h *handler) Version() string {
return "v1"
}
func (h *handler) Registry(ws *restful.WebService) {
tags := []string{h.Name()}
ws.Route(ws.POST("/").To(h.CreatePolicy).
Doc("create a policy").
Metadata(restfulspec.KeyOpenAPITags, tags).
Reads(policy.CreatePolicyRequest{}).
Writes(response.NewData(policy.Policy{})))
}
func init() {
app.RegistryRESTfulApp(h)
}
Go
1
https://gitee.com/wshile/keyauth.git
git@gitee.com:wshile/keyauth.git
wshile
keyauth
keyauth
v0.0.7

搜索帮助