Documentation
¶
Index ¶
- Constants
- Variables
- type Api
- func (a *Api) AddCorsMiddleware()
- 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) 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) 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
- func (c *Context) GetAesTextBodyToJson(jsonData interface{}) error
- func (c *Context) GetBody() ([]byte, error)
- func (c *Context) GetEccBodyToJson(jsonData interface{}) error
- func (c *Context) GetEccTextBodyToJson(jsonData interface{}) error
- func (c *Context) ResponseAesStr(jsonResponse interface{})
- func (c *Context) ResponseEccStr(api *Api, jsonResponse interface{})
- type EccConfig
- type JsonMap
- type Response
- type StringMap
Constants ¶
View Source
const (
AuthUserKey = "user" // 是基本身份验证中用户凭据的cookie名称。
)
Variables ¶
View Source
var ( Password *zdpgo_password.Password Log *zdpgo_log.Log )
Functions ¶
This section is empty.
Types ¶
type Api ¶ added in v1.1.4
type Api struct {
Config *Config // 配置对象
Log *zdpgo_log.Log // 日志对象
App *gin.Engine // 核心App对象
Password *zdpgo_password.Password // 密码加密
}
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) 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 *gin.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"` // 是否为debug模式
LogFilePath string `yaml:"log_file_path" json:"log_file_path"` // 日志路径
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
Ecc EccConfig `yaml:"ecc" json:"ecc"`
}
type Context ¶ added in v1.1.7
Context 重命名gin上下文
func (*Context) GetAesTextBodyToJson ¶ added in v1.2.0
func (*Context) GetEccBodyToJson ¶ added in v1.1.8
GetEccBodyToJson 读取ECC加密的内容并解析为JSON数据
func (*Context) GetEccTextBodyToJson ¶ added in v1.1.9
func (*Context) ResponseAesStr ¶ added in v1.2.0
func (c *Context) ResponseAesStr(jsonResponse interface{})
func (*Context) ResponseEccStr ¶ added in v1.1.9
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
core
|
|
|
examples
|
|
|
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
|
|
|
post_ecc
command
|
|
|
post_ecctext
command
|
|
|
validator
command
|
|
|
Package api implements a HTTP web framework called api.
|
Package api implements a HTTP web framework called api. |
|
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.