代码拉取完成,页面将自动刷新
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/token"
)
var (
h = &handler{}
)
type handler struct {
service token.ServiceServer
log logger.Logger
}
func (h *handler) Config() error {
h.log = zap.L().Named(token.AppName)
h.service = app.GetGrpcApp(token.AppName).(token.ServiceServer)
return nil
}
func (h *handler) Name() string {
return token.AppName
}
func (h *handler) Version() string {
return "v1"
}
func (h *handler) Registry(ws *restful.WebService) {
tags := []string{"tokens"}
ws.Route(ws.POST("/issue").To(h.IssueToken).
Doc("issue a token").
Metadata(restfulspec.KeyOpenAPITags, tags).
Reads(token.IssueTokenRequest{}).
Writes(response.NewData(token.Token{})))
ws.Route(ws.GET("/").To(h.QueryToken).
Doc("get all tokens").
Metadata(restfulspec.KeyOpenAPITags, tags).
Metadata("action", "list").
Reads(token.IssueTokenRequest{}).
Writes(response.NewData(token.TokenSet{})).
Returns(200, "OK", token.TokenSet{}))
ws.Route(ws.GET("/validate").To(h.ValidateToken).
Doc("validate tokens").
Metadata(restfulspec.KeyOpenAPITags, tags).
Metadata("action", "get").
Reads(token.ValidateTokenRequest{}).
Writes(response.NewData(token.Token{})).
Returns(200, "OK", token.Token{}))
ws.Route(ws.POST("/revolk").To(h.RevolkToken).
Doc("revolk token").
Param(ws.PathParameter("id", "identifier of the token").DataType("integer").DefaultValue("1")).
Metadata(restfulspec.KeyOpenAPITags, tags).
Metadata("action", "delete"))
//ws.Route(ws.PUT("/{id}").To(h.UpdateToken).
// Doc("update a token").
// Param(ws.PathParameter("id", "identifier of the token").DataType("string")).
// Metadata(restfulspec.KeyOpenAPITags, tags).
// Reads(token.IssueTokenRequest{}))
//
//ws.Route(ws.DELETE("/{id}").To(h.RevolkToken).
// Doc("delete a token").
// Metadata(restfulspec.KeyOpenAPITags, tags).
// Param(ws.PathParameter("id", "identifier of the token").DataType("string")))
}
func init() {
app.RegistryRESTfulApp(h)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。