Documentation ¶
Index ¶
- Constants
- type Config
- type Context
- func (ctx *Context) Abort()
- func (ctx *Context) Caller(err error) error
- func (ctx *Context) Form(key string) string
- func (ctx *Context) FormParam(key string) (string, bool)
- func (ctx *Context) FormParams() url.Values
- func (ctx *Context) GetValue(key interface{}) interface{}
- func (ctx *Context) IsAborted() bool
- func (ctx *Context) JSON(status int, data interface{}, charset ...string) error
- func (ctx *Context) ParseJSON(obj interface{}) error
- func (ctx *Context) Path(key string) string
- func (ctx *Context) PathParams() PathParams
- func (ctx *Context) Post(key string) string
- func (ctx *Context) PostParam(key string) (string, bool)
- func (ctx *Context) PostParams() url.Values
- func (ctx *Context) Query(key string) string
- func (ctx *Context) QueryParam(key string) (string, bool)
- func (ctx *Context) QueryParams() url.Values
- func (ctx *Context) Redirect(code int, url string) error
- func (ctx *Context) RemoteIP() string
- func (ctx *Context) SetValue(key, value interface{})
- func (ctx *Context) Status(status int) (err error)
- func (ctx *Context) String(status int, data string, charset ...string) (err error)
- type Engine
- type Event
- type EventHandler
- type Handler
- type HandlersChain
- type PathParam
- type PathParams
- type Router
- func (router *Router) Any(relativePath string, handlers ...Handler) RouterInterface
- func (router *Router) Append(handlers ...Handler) RouterInterface
- func (router *Router) DELETE(urlPath string, handlers ...Handler) RouterInterface
- func (router *Router) Dir(urlPath, absPath string) RouterInterface
- func (router *Router) File(urlPath, absPath string) RouterInterface
- func (router *Router) GET(urlPath string, handlers ...Handler) RouterInterface
- func (router *Router) Group(urlPath string, handlers ...Handler) *Router
- func (router *Router) HEAD(urlPath string, handlers ...Handler) RouterInterface
- func (router *Router) Handle(method, urlPath string, handlers ...Handler) RouterInterface
- func (router *Router) OPTIONS(urlPath string, handlers ...Handler) RouterInterface
- func (router *Router) PATCH(urlPath string, handlers ...Handler) RouterInterface
- func (router *Router) POST(urlPath string, handlers ...Handler) RouterInterface
- func (router *Router) PUT(urlPath string, handlers ...Handler) RouterInterface
- type RouterInterface
Constants ¶
View Source
const MaxMultipartMemory = 1 << 20
默认body限制
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶ added in v0.8.0
type Config struct { RootPath string // 应用的根路径 AllowOrigins string ExposeHeaders string AllowMethods string AllowHeaders string Charset string // 响应的字符集,默认是UTF-8 MaxMultipartMemory int64 // 允许的请求Body大小(默认1 << 20 = 1MB) EventHandler EventHandler // 事件-处理器函数,如果不赋值,则不启用事件 UseRawPath bool // 使用url.RawPath查找参数 UnescapePathValues bool // 反转义路由参数 EventTrace bool // 事件-启用跟踪信息 EventShortPath bool // 事件-启用短文件路径 EventHandlerError bool // 事件-启用处理器返回的错误 EventSource bool // 事件-启用来源 Recover bool // 自动恢复处理器的panic CORS bool // 是否启用自动CORS处理 AllowCredentials bool }
引擎配置
type Context ¶
type Context struct { ResponseWriter http.ResponseWriter Request *http.Request // contains filtered or unexported fields }
上下文
func (*Context) FormParams ¶ added in v1.1.0
获取所有GET/POST/PUT参数值
func (*Context) GetValue ¶ added in v0.7.0
func (ctx *Context) GetValue(key interface{}) interface{}
从Context中取值
func (*Context) PostParams ¶ added in v1.1.0
获取所有POST/PATCH/PUT参数值
func (*Context) QueryParam ¶ added in v1.1.0
获取某个GET参数
func (*Context) QueryParams ¶ added in v1.1.0
获取所有GET参数值
type Engine ¶ added in v1.0.0
type Engine struct { *Router // 路由器 Config *Config // 配置 // contains filtered or unexported fields }
引擎
type Event ¶
type Event struct { Status int // HTTP状态码 Message error // 消息(error) Source *_Source // 来源 Trace []string // 跟踪 ResponseWriter http.ResponseWriter Request *http.Request }
事件
type PathParams ¶ added in v1.0.0
type PathParams []PathParam
func (PathParams) Value ¶ added in v1.0.0
func (ps PathParams) Value(name string) (value string)
获得路径参数值
type Router ¶ added in v1.0.0
type Router struct { Handlers HandlersChain // contains filtered or unexported fields }
路由组
func (*Router) Any ¶ added in v1.0.0
func (router *Router) Any(relativePath string, handlers ...Handler) RouterInterface
注册所有路由
func (*Router) Append ¶ added in v1.0.0
func (router *Router) Append(handlers ...Handler) RouterInterface
添加处理器
func (*Router) DELETE ¶ added in v1.0.0
func (router *Router) DELETE(urlPath string, handlers ...Handler) RouterInterface
注册DELETE路由
func (*Router) Dir ¶ added in v1.0.0
func (router *Router) Dir(urlPath, absPath string) RouterInterface
注册一个响应服务端目录的路由
func (*Router) File ¶ added in v1.0.0
func (router *Router) File(urlPath, absPath string) RouterInterface
注册一个响应服务端文件的路由
func (*Router) GET ¶ added in v1.0.0
func (router *Router) GET(urlPath string, handlers ...Handler) RouterInterface
注册GET路由
func (*Router) HEAD ¶ added in v1.0.0
func (router *Router) HEAD(urlPath string, handlers ...Handler) RouterInterface
注册HEAD路由
func (*Router) Handle ¶ added in v1.0.0
func (router *Router) Handle(method, urlPath string, handlers ...Handler) RouterInterface
注册自定义HTTP方法的路由
func (*Router) OPTIONS ¶ added in v1.0.0
func (router *Router) OPTIONS(urlPath string, handlers ...Handler) RouterInterface
注册OPTIONS路由
func (*Router) PATCH ¶ added in v1.0.0
func (router *Router) PATCH(urlPath string, handlers ...Handler) RouterInterface
注册PATCH路由
type RouterInterface ¶ added in v1.0.0
type RouterInterface interface { Append(...Handler) RouterInterface Handle(string, string, ...Handler) RouterInterface Any(string, ...Handler) RouterInterface GET(string, ...Handler) RouterInterface POST(string, ...Handler) RouterInterface DELETE(string, ...Handler) RouterInterface PATCH(string, ...Handler) RouterInterface PUT(string, ...Handler) RouterInterface OPTIONS(string, ...Handler) RouterInterface HEAD(string, ...Handler) RouterInterface File(string, string) RouterInterface Dir(string, string) RouterInterface }
路由组接口
Click to show internal directories.
Click to hide internal directories.