1 Star 0 Fork 0

Codey/swag

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
swagger.go 726 Bytes
一键复制 编辑 原始数据 按行查看 历史
Eason Lin 提交于 2018-06-12 18:57 . Refine comments (#150)
package swag
import (
"errors"
"sync"
)
// Name is a unique name be used to register swag instance.
const Name = "swagger"
var (
swaggerMu sync.RWMutex
swag Swagger
)
// Swagger is a interface to read swagger document.
type Swagger interface {
ReadDoc() string
}
// Register registers swagger for given name.
func Register(name string, swagger Swagger) {
swaggerMu.Lock()
defer swaggerMu.Unlock()
if swagger == nil {
panic("swagger is nil")
}
if swag != nil {
panic("Register called twice for swag: " + name)
}
swag = swagger
}
// ReadDoc reads swagger document.
func ReadDoc() (string, error) {
if swag != nil {
return swag.ReadDoc(), nil
}
return "", errors.New("not yet registered swag")
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/codey-repositories/swag.git
[email protected]:codey-repositories/swag.git
codey-repositories
swag
swag
master

搜索帮助