Documentation ¶
Index ¶
- Constants
- Variables
- func BeginTransaction(source ...Source) *begin
- func CheckParams(req any)
- func Db(tableName string, source ...Source) (db *tdb)
- func ExecSql(source ...Source) *sqlx.DB
- type Context
- func (ctx *Context) BindStructValidate(req any, defaultFormMaxMemory ...int64)
- func (ctx *Context) ClientIP() string
- func (ctx *Context) Download(fileName string)
- func (ctx *Context) Fail(message string, option ...FailOption)
- func (ctx *Context) FormFile(key string, defaultFormMaxMemory ...int64) *multipart.FileHeader
- func (ctx *Context) FormFiles(key string, defaultFormMaxMemory ...int64) []*multipart.FileHeader
- func (ctx *Context) Get(key string) (value any, ok bool)
- func (ctx *Context) GetDefaultQuery(key string, value string) string
- func (ctx *Context) GetQuery(key string) string
- func (ctx *Context) HTML(html string)
- func (ctx *Context) JSON(code int, data any)
- func (ctx *Context) Next()
- func (ctx *Context) PostDefaultForm(key string, value any, defaultFormMaxMemory ...int64) gjson.Result
- func (ctx *Context) PostForm(key string, defaultFormMaxMemory ...int64) gjson.Result
- func (ctx *Context) Redirect(url string)
- func (ctx *Context) Set(key string, value any)
- func (ctx *Context) Stream(data io.Reader)
- func (ctx *Context) Success(data interface{}, option ...SuccessOption)
- func (ctx *Context) View(name string, data any, expression ...string)
- func (ctx *Context) XML(code int, data any)
- type CountOption
- type DecrOption
- type DeleteOption
- type Engine
- func (group *Engine) ALL(relativePath string, handlerFunc HandlerFunc, middlewareFunc ...MiddlewareFunc)
- func (group *Engine) Bind()
- func (group *Engine) DELETE(relativePath string, handlerFunc HandlerFunc, middlewareFunc ...MiddlewareFunc)
- func (group *Engine) GET(relativePath string, handlerFunc HandlerFunc, middlewareFunc ...MiddlewareFunc)
- func (group *Engine) Group(relativePath string, middlewareFunc ...MiddlewareFunc) *routerGroup
- func (group *Engine) HEAD(relativePath string, handlerFunc HandlerFunc, middlewareFunc ...MiddlewareFunc)
- func (group *Engine) OPTIONS(relativePath string, handlerFunc HandlerFunc, middlewareFunc ...MiddlewareFunc)
- func (group *Engine) PATCH(relativePath string, handlerFunc HandlerFunc, middlewareFunc ...MiddlewareFunc)
- func (group *Engine) POST(relativePath string, handlerFunc HandlerFunc, middlewareFunc ...MiddlewareFunc)
- func (group *Engine) PUT(relativePath string, handlerFunc HandlerFunc, middlewareFunc ...MiddlewareFunc)
- func (engine *Engine) Run()
- func (engine *Engine) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (group *Engine) Use(middlewareFunc ...MiddlewareFunc)
- type Exception
- type FailOption
- type FindOneOption
- type HandlerFunc
- type IncrOption
- type InsertAllOption
- type InsertOption
- type MiddlewareFunc
- type SelectOption
- type Source
- type SuccessOption
- type UpdateOption
Constants ¶
View Source
const StartText = `` /* 265-byte string literal not displayed */
Variables ¶
View Source
var ErrorCode = &errorCode{
VALIDATE: 10001,
TokenExpire: 10002,
EXCEPTION: 20001,
MySqlError: 20002,
}
ErrorCode 初始化错误码
Functions ¶
func BeginTransaction ¶
func BeginTransaction(source ...Source) *begin
BeginTransaction 开启事务,如果不传数据源默认走的是配置文件里默认的,传了可以指定任意的数据源
func CheckParams ¶
func CheckParams(req any)
Types ¶
type Context ¶
type Context struct { Response http.ResponseWriter Request *http.Request // contains filtered or unexported fields }
Context 上下文
func (*Context) BindStructValidate ¶
BindStructValidate 结构体参数映射,具有参数验证功能
func (*Context) FormFile ¶
func (ctx *Context) FormFile(key string, defaultFormMaxMemory ...int64) *multipart.FileHeader
FormFile 获取文件
func (*Context) FormFiles ¶
func (ctx *Context) FormFiles(key string, defaultFormMaxMemory ...int64) []*multipart.FileHeader
FormFiles 获取多个文件
func (*Context) GetDefaultQuery ¶
GetDefaultQuery 获取GET请求参数,如果没有内容赋默认值
func (*Context) PostDefaultForm ¶
func (ctx *Context) PostDefaultForm(key string, value any, defaultFormMaxMemory ...int64) gjson.Result
PostDefaultForm 获取POST请求参数,如果没有内容赋默认值
func (*Context) Success ¶
func (ctx *Context) Success(data interface{}, option ...SuccessOption)
Success 成功输出信息
type CountOption ¶
type DecrOption ¶
type DeleteOption ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine 定义引擎结构体
func (*Engine) ALL ¶
func (group *Engine) ALL(relativePath string, handlerFunc HandlerFunc, middlewareFunc ...MiddlewareFunc)
ALL ALL请求
func (*Engine) DELETE ¶
func (group *Engine) DELETE(relativePath string, handlerFunc HandlerFunc, middlewareFunc ...MiddlewareFunc)
DELETE DELETE请求
func (*Engine) GET ¶
func (group *Engine) GET(relativePath string, handlerFunc HandlerFunc, middlewareFunc ...MiddlewareFunc)
GET GET请求
func (*Engine) Group ¶
func (group *Engine) Group(relativePath string, middlewareFunc ...MiddlewareFunc) *routerGroup
Group 分组路由
func (*Engine) HEAD ¶
func (group *Engine) HEAD(relativePath string, handlerFunc HandlerFunc, middlewareFunc ...MiddlewareFunc)
HEAD HEAD请求
func (*Engine) OPTIONS ¶
func (group *Engine) OPTIONS(relativePath string, handlerFunc HandlerFunc, middlewareFunc ...MiddlewareFunc)
OPTIONS OPTIONS请求
func (*Engine) PATCH ¶
func (group *Engine) PATCH(relativePath string, handlerFunc HandlerFunc, middlewareFunc ...MiddlewareFunc)
PATCH PATCH请求
func (*Engine) POST ¶
func (group *Engine) POST(relativePath string, handlerFunc HandlerFunc, middlewareFunc ...MiddlewareFunc)
POST POST请求
func (*Engine) PUT ¶
func (group *Engine) PUT(relativePath string, handlerFunc HandlerFunc, middlewareFunc ...MiddlewareFunc)
PUT PUT请求
type Exception ¶
type Exception struct { StateCode int `json:"stateCode"` ErrorCode int `json:"errorCode"` Message string `json:"message"` Error error `json:"error"` }
Exception 统一异常
type FailOption ¶ added in v1.0.3
FailOption 自定义
type FindOneOption ¶
type IncrOption ¶
type InsertAllOption ¶
type InsertOption ¶
type SelectOption ¶
type SuccessOption ¶ added in v1.0.3
SuccessOption 自定义
Click to show internal directories.
Click to hide internal directories.