Documentation
¶
Index ¶
- func NewGinWithLog(isDetailLogger bool) *gin.Engine
- type Api
- func (a *Api) AddCorsMiddleware()
- func (a *Api) AddUploadRouter(routerPath string, fileName string, saveDir string, ...)
- func (a *Api) CreateDirs(filePath string) error
- func (a *Api) GetBasicAuthGroup(routerPath string, accounts map[string]string) (group *gin.RouterGroup)
- func (a *Api) InitValidator() (err error)
- func (a *Api) IsExists(path string) bool
- func (a *Api) Run(exitFuncList ...func())
- func (a *Api) SetApp(app *gin.Engine)
- func (a *Api) Validate(data interface{}) (errData map[string]string)
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewGinWithLog ¶
NewGinWithLog 根据是否使用详细日志创建Gin的实例 @param isDetailLogger 是否使用详细日志,开启后,会记录请求头,form,body的详细信息
Types ¶
type Api ¶ added in v1.1.4
Api API核心对象
func (*Api) AddCorsMiddleware ¶ added in v1.1.4
func (a *Api) AddCorsMiddleware()
AddCorsMiddleware 添加跨域中间件
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
func (a *Api) GetBasicAuthGroup(routerPath string, accounts map[string]string) (group *gin.RouterGroup)
GetBasicAuthGroup 获取基本权限校验路由组
func (*Api) InitValidator ¶ added in v1.1.4
InitValidator 初始化校验器
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
}
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
core
|
|
|
examples
|
|
|
basic
command
|
|
|
basic_auth
command
|
|
|
file_upload
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
|
|
|
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.