1 Star 0 Fork 0

han/keyauth-g7

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
http.go 1.38 KB
一键复制 编辑 原始数据 按行查看 历史
han 提交于 2023-07-23 23:49 . 11
package api
import (
"gitee.com/hanshengjian/keyauth-g7/apps/token"
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 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{h.Name()}
ws.Route(ws.POST("/issue").To(h.IssueToken).
Doc("issue token").
Metadata(restfulspec.KeyOpenAPITags, tags).
Reads(token.IssueTokenRequest{}).
Writes(response.NewData(token.Token{})))
ws.Route(ws.GET("/validate").To(h.ValidateToken).
Doc("validate token").
Metadata(restfulspec.KeyOpenAPITags, tags).
Metadata("action", "get"))
ws.Route(ws.POST("/revolk").To(h.RevolkToken).
Doc("revolk token").
Param(ws.PathParameter("id", "identifier of the user").DataType("integer").DefaultValue("1")).
Metadata(restfulspec.KeyOpenAPITags, tags).
Metadata("action", "delete"))
}
func init() {
app.RegistryRESTfulApp(h)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/hanshengjian/keyauth-g7.git
git@gitee.com:hanshengjian/keyauth-g7.git
hanshengjian
keyauth-g7
keyauth-g7
23cb155209a5

搜索帮助

A270a887 8829481 3d7a4017 8829481