1 Star 0 Fork 0

谈子文 / keyauth-tz

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
http.go 2.34 KB
一键复制 编辑 原始数据 按行查看 历史
谈子文 提交于 2023-10-27 00:55 . 更新policy 和 role api create 功能
package api
import (
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"
"gitee.com/talk-about-articles/keyauth-tz/apps/policy"
)
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{"policys"}
ws.Route(ws.POST("").To(h.CreatePolicy).
Doc("create a policy").
Metadata(restfulspec.KeyOpenAPITags, tags).
Reads(policy.CreatePolicyRequest{}).
Writes(response.NewData(policy.Policy{})))
//ws.Route(ws.GET("/").To(h.QueryPolicy).
// Doc("get all policys").
// Metadata(restfulspec.KeyOpenAPITags, tags).
// Metadata("action", "list").
// Reads(policy.CreatePolicyRequest{}).
// Writes(response.NewData(policy.PolicySet{})).
// Returns(200, "OK", policy.PolicySet{}))
//
//ws.Route(ws.GET("/{id}").To(h.DescribePolicy).
// Doc("get a policy").
// Param(ws.PathParameter("id", "identifier of the policy").DataType("integer").DefaultValue("1")).
// Metadata(restfulspec.KeyOpenAPITags, tags).
// Writes(response.NewData(policy.Policy{})).
// Returns(200, "OK", response.NewData(policy.Policy{})).
// Returns(404, "Not Found", nil))
//
//ws.Route(ws.PUT("/{id}").To(h.UpdatePolicy).
// Doc("update a policy").
// Param(ws.PathParameter("id", "identifier of the policy").DataType("string")).
// Metadata(restfulspec.KeyOpenAPITags, tags).
// Reads(policy.CreatePolicyRequest{}))
//
//ws.Route(ws.PATCH("/{id}").To(h.PatchPolicy).
// Doc("patch a policy").
// Param(ws.PathParameter("id", "identifier of the policy").DataType("string")).
// Metadata(restfulspec.KeyOpenAPITags, tags).
// Reads(policy.CreatePolicyRequest{}))
//
//ws.Route(ws.DELETE("/{id}").To(h.DeletePolicy).
// Doc("delete a policy").
// Metadata(restfulspec.KeyOpenAPITags, tags).
// Param(ws.PathParameter("id", "identifier of the policy").DataType("string")))
}
func init() {
app.RegistryRESTfulApp(h)
}
Go
1
https://gitee.com/talk-about-articles/keyauth-tz.git
git@gitee.com:talk-about-articles/keyauth-tz.git
talk-about-articles
keyauth-tz
keyauth-tz
v1.0.33

搜索帮助