Documentation
¶
Index ¶
- func Make[T any](c *Context) (T, error)
- type Context
- func (c *Context) Abort()
- func (c *Context) AbortWithJSON(code int, obj any)
- func (c *Context) AbortWithStatus(code int)
- func (c *Context) Error(message string)
- func (c *Context) ErrorWithCode(code int, message string)
- func (c *Context) File(name string) (*multipart.FileHeader, error)
- func (c *Context) HTML(code int, name string, obj any)
- func (c *Context) Input(key string, defaultValue ...string) string
- func (c *Context) InputBool(key string, defaultValue ...bool) bool
- func (c *Context) InputInt(key string, defaultValue ...int) int
- func (c *Context) IsAborted() bool
- func (c *Context) JSON(code int, obj any)
- func (c *Context) Redirect(code int, location string)
- func (c *Context) SaveFile(name, dst string) error
- func (c *Context) SetUser(user any)
- func (c *Context) String(code int, format string, values ...any)
- func (c *Context) Success(data any)
- func (c *Context) User() (any, bool)
- func (c *Context) Validate(obj any) error
- type HandlerFunc
- type Middleware
- type Route
- type Router
- func (r *Router) Any(path string, handler HandlerFunc) *Route
- func (r *Router) Delete(path string, handler HandlerFunc) *Route
- func (r *Router) Engine() *gin.Engine
- func (r *Router) Get(path string, handler HandlerFunc) *Route
- func (r *Router) Group(prefix string, callback func(*Router)) *Router
- func (r *Router) Middleware(middleware ...HandlerFunc) *Router
- func (r *Router) Options(path string, handler HandlerFunc) *Route
- func (r *Router) Patch(path string, handler HandlerFunc) *Route
- func (r *Router) Post(path string, handler HandlerFunc) *Route
- func (r *Router) Put(path string, handler HandlerFunc) *Route
- func (r *Router) Run(addr ...string) error
- func (r *Router) SetMode(mode string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Context ¶
Context 请求上下文
func (*Context) AbortWithJSON ¶
AbortWithJSON 中止请求并返回 JSON
func (*Context) AbortWithStatus ¶
AbortWithStatus 中止请求并返回状态码
func (*Context) ErrorWithCode ¶
ErrorWithCode 返回带错误码的错误响应
func (*Context) File ¶
func (c *Context) File(name string) (*multipart.FileHeader, error)
File 获取上传文件
type Route ¶
type Route struct {
// contains filtered or unexported fields
}
Route 路由
func (*Route) Middleware ¶
func (r *Route) Middleware(middleware ...HandlerFunc) *Route
Middleware 为路由添加中间件
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router Laravel 风格的路由器
func (*Router) Delete ¶
func (r *Router) Delete(path string, handler HandlerFunc) *Route
Delete 注册 DELETE 路由
func (*Router) Middleware ¶
func (r *Router) Middleware(middleware ...HandlerFunc) *Router
Middleware 添加中间件
func (*Router) Options ¶
func (r *Router) Options(path string, handler HandlerFunc) *Route
Options 注册 OPTIONS 路由
func (*Router) Patch ¶
func (r *Router) Patch(path string, handler HandlerFunc) *Route
Patch 注册 PATCH 路由
Click to show internal directories.
Click to hide internal directories.