Documentation
¶
Index ¶
- Constants
- Variables
- func SetLog(log *zdpgo_log.Log)
- type Api
- func (a *Api) AddCorsMiddleware()
- func (a *Api) AddHealthCheckRouter()
- func (a *Api) AddRateLimitMiddleware()
- func (a *Api) AddStaticFSRouter(routerPath string, fsObj fs.FS)
- func (a *Api) AddStaticRouter(routerPath string, dirPath string)
- func (a *Api) AddUploadRouter(routerPath string, fileName string, saveDir string, ...)
- func (a *Api) Any(method, routerPath string, handleFuncList ...func(ctx *Context))
- func (a *Api) CreateDirs(filePath string) error
- func (a *Api) Delete(routerPath string, handleFuncList ...func(ctx *Context))
- func (a *Api) Get(routerPath string, handleFuncList ...func(ctx *Context))
- func (a *Api) GetBasicAuthGroup(routerPath string, accounts StringMap) (group *ApiGroup)
- func (a *Api) GetMd5(data string) string
- func (a *Api) InitValidator() (err error)
- func (a *Api) IsExists(path string) bool
- func (a *Api) Patch(routerPath string, handleFuncList ...func(ctx *Context))
- func (a *Api) Post(routerPath string, handleFuncList ...func(ctx *Context))
- func (a *Api) Put(routerPath string, handleFuncList ...func(ctx *Context))
- func (a *Api) Run(exitFuncList ...func())
- func (a *Api) SetApp(app *gin.Engine)
- func (a *Api) SetLog(log *zdpgo_log.Log)
- func (a *Api) Validate(data interface{}) (errData map[string]string)
- type ApiGroup
- func (g *ApiGroup) Any(method, routerPath string, handleFuncList ...func(ctx *Context))
- func (g *ApiGroup) Delete(routerPath string, handleFuncList ...func(ctx *Context))
- func (g *ApiGroup) Get(routerPath string, handleFuncList ...func(ctx *Context))
- func (g *ApiGroup) Patch(routerPath string, handleFuncList ...func(ctx *Context))
- func (g *ApiGroup) Post(routerPath string, handleFuncList ...func(ctx *Context))
- func (g *ApiGroup) Put(routerPath string, handleFuncList ...func(ctx *Context))
- type Config
- type Context
- type JsonMap
- type MiddlewareConfig
- type Response
- type RouterConfig
- type StringMap
Constants ¶
View Source
const (
AuthUserKey = "user" // 是基本身份验证中用户凭据的cookie名称。
)
Variables ¶
View Source
var ( Password *zdpgo_password.Password Log *zdpgo_log.Log )
Functions ¶
Types ¶
type Api ¶ added in v1.1.4
Api API核心对象
func NewWithConfig ¶ added in v1.1.4
NewWithConfig 根据配置创建API
func (*Api) AddCorsMiddleware ¶ added in v1.1.4
func (a *Api) AddCorsMiddleware()
AddCorsMiddleware 添加跨域中间件
func (*Api) AddHealthCheckRouter ¶ added in v1.2.4
func (a *Api) AddHealthCheckRouter()
AddHealthCheckRouter 添加健康检查接口
func (*Api) AddRateLimitMiddleware ¶ added in v1.2.4
func (a *Api) AddRateLimitMiddleware()
AddRateLimitMiddleware 添加请求速率中间件
func (*Api) AddStaticFSRouter ¶ added in v1.1.6
AddStaticFSRouter 添加嵌入式文件系统作为静态目录
func (*Api) AddStaticRouter ¶ added in v1.1.6
AddStaticRouter 添加静态文件目录
func (*Api) AddUploadRouter ¶ added in v1.1.4
func (a *Api) AddUploadRouter( routerPath string, fileName string, saveDir string, handleResultList ...func(c *Context, file *multipart.FileHeader, err error))
AddUploadRouter 添加文件上传路由 @param routerPath 路由路径,比如:/upload @param fileName 上传文件的表单名称,比如:file @param saveDir 文件的上传路径,比如:./uploads @param handleResultList 处理结果的方法列表,用户可以自定义文件上传后的返回内容,处理错误信息
func (*Api) CreateDirs ¶ added in v1.1.4
CreateDirs 调用os.MkdirAll递归创建文件夹
func (*Api) GetBasicAuthGroup ¶ added in v1.1.4
GetBasicAuthGroup 获取基本权限校验路由组
func (*Api) InitValidator ¶ added in v1.1.4
InitValidator 初始化校验器
type ApiGroup ¶ added in v1.1.7
type ApiGroup struct {
gin.RouterGroup
}
ApiGroup API分组
type Config ¶ added in v1.1.4
type Config struct {
Debug bool `yaml:"debug" json:"debug"`
Host string `yaml:"host" json:"host"` // 启动地址,默认0.0.0.0
Port int `yaml:"port" json:"port"` // 启动端口号,默认3333
UploadFileSize int64 `yaml:"upload_file_size" json:"upload_file_size"` // 上传文件大小限制(M),默认33
RateLimit uint64 `yaml:"rate_limit" json:"rate_limit"` // 请求速率,默认3333
Middleware MiddlewareConfig `yaml:"middleware" json:"middleware"` // 中间件
Router RouterConfig `yaml:"router" json:"router"` // 路由配置
}
type Context ¶ added in v1.1.7
Context 重命名gin上下文
func (*Context) GetAesTextBodyToJson ¶ added in v1.2.0
func (*Context) GetResponseSuccess ¶ added in v1.2.1
获取成功的响应
func (*Context) ResponseAesStr ¶ added in v1.2.0
func (c *Context) ResponseAesStr(jsonResponse interface{})
type MiddlewareConfig ¶ added in v1.2.4
type RouterConfig ¶ added in v1.2.4
type RouterConfig struct {
HealthCheck bool `yaml:"health_check" json:"health_check"`
}
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package codec provides a High Performance, Feature-Rich Idiomatic Go 1.4+ codec/encoding library for binc, msgpack, cbor, json.
|
Package codec provides a High Performance, Feature-Rich Idiomatic Go 1.4+ codec/encoding library for binc, msgpack, cbor, json. |
|
core
|
|
|
examples
|
|
|
basic
command
|
|
|
grpc/api
command
|
|
|
grpc/grpc
command
|
|
|
grpc/pb
Package helloworld is a generated protocol buffer package.
|
Package helloworld is a generated protocol buffer package. |
|
multiple_service
command
|
|
|
post_aes
command
|
|
|
rate_limit
command
|
|
|
validator
command
|
|
|
Package api implements a HTTP web framework called api.
|
Package api implements a HTTP web framework called api. |
|
cmd
command
|
|
|
Package ratelimit provides an efficient token bucket implementation that can be used to limit the rate of arbitrary things.
|
Package ratelimit provides an efficient token bucket implementation that can be used to limit the rate of arbitrary things. |
|
Package validator implements value validations for structs and individual fields based on tags.
|
Package validator implements value validations for structs and individual fields based on tags. |
|
Package yaml implements YAML support for the Go language.
|
Package yaml implements YAML support for the Go language. |
Click to show internal directories.
Click to hide internal directories.