Documentation ¶
Index ¶
- type App
- type Context
- func (ctx Context) Break(err error) (Context, error)
- func (ctx Context) ContextValue(key string) interface{}
- func (ctx Context) Continue() (Context, error)
- func (ctx Context) Event(err error) error
- func (ctx Context) FormValue(key string) ReqValue
- func (ctx Context) FormValues() url.Values
- func (ctx Context) PostValues() url.Values
- func (ctx Context) QueryValue(key string) ReqValue
- func (ctx Context) QueryValues() url.Values
- func (ctx Context) RawFormValue(key string) string
- func (ctx Context) RawQueryValue(key string) string
- func (ctx Context) RawRouteValue(key string) string
- func (ctx Context) RealIP() string
- func (ctx Context) Redirect(code int, url string) error
- func (ctx Context) RouteValue(key string) ReqValue
- func (ctx Context) RouteValues() []httprouter.Param
- func (ctx *Context) SetContextValue(key string, value interface{})
- type Event
- type EventHandler
- type Handler
- type MiddlewareHandler
- type ReqValue
- func (bv ReqValue) Bool(rules ...filter.Rule) (bool, error)
- func (bv ReqValue) Float32(rules ...filter.Rule) (float32, error)
- func (bv ReqValue) Float64(rules ...filter.Rule) (float64, error)
- func (bv ReqValue) Int(rules ...filter.Rule) (int, error)
- func (bv ReqValue) Int32(rules ...filter.Rule) (int32, error)
- func (bv ReqValue) Int64(rules ...filter.Rule) (int64, error)
- func (bv ReqValue) MustBool(def bool, rules ...filter.Rule) bool
- func (bv ReqValue) MustFloat32(def float32, rules ...filter.Rule) float32
- func (bv ReqValue) MustFloat64(def float64, rules ...filter.Rule) float64
- func (bv ReqValue) MustInt(def int, rules ...filter.Rule) int
- func (bv ReqValue) MustInt32(def int32, rules ...filter.Rule) int32
- func (bv ReqValue) MustInt64(def int64, rules ...filter.Rule) int64
- func (bv ReqValue) MustString(def string, rules ...filter.Rule) string
- func (bv ReqValue) MustUint32(def uint32, rules ...filter.Rule) uint32
- func (bv ReqValue) MustUint64(def uint64, rules ...filter.Rule) uint64
- func (bv ReqValue) String(rules ...filter.Rule) (string, error)
- func (bv ReqValue) Uint32(rules ...filter.Rule) (uint32, error)
- func (bv ReqValue) Uint64(rules ...filter.Rule) (uint64, error)
- type RouterGroup
- func (r *RouterGroup) DELETE(path string, handler Handler, middlewareHandlers ...MiddlewareHandler)
- func (r *RouterGroup) FILE(url string, local string)
- func (r *RouterGroup) GET(path string, handler Handler, middlewareHandlers ...MiddlewareHandler)
- func (r *RouterGroup) GROUP(path string, middlewareHandlers ...MiddlewareHandler) RouterGroup
- func (r *RouterGroup) HEAD(path string, handler Handler, middlewareHandlers ...MiddlewareHandler)
- func (r *RouterGroup) Handle(method string, path string, handler Handler, ...)
- func (r *RouterGroup) OPTIONS(path string, handler Handler, middlewareHandlers ...MiddlewareHandler)
- func (r *RouterGroup) PATCH(path string, handler Handler, middlewareHandlers ...MiddlewareHandler)
- func (r *RouterGroup) PATH(url string, local string, list bool)
- func (r *RouterGroup) POST(path string, handler Handler, middlewareHandlers ...MiddlewareHandler)
- func (r *RouterGroup) PUT(path string, handler Handler, middlewareHandlers ...MiddlewareHandler)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct { // 事件配置 Event struct { Handler EventHandler // 事件处理器,如果未传值则认为不记录事件 EnableTrace bool // 启用500事件的跟踪(影响性能) ShortCaller bool // 缩短事件触发的源码文件名(仅记录源码文件名,仅对ctx.Return触发的500事件有效)s } // 路由器 Router RouterGroup // contains filtered or unexported fields }
App 框架实例
type Context ¶
type Context struct { Request *http.Request ResponseWriter http.ResponseWriter Next bool // 继续执行下一个中间件或处理器 // contains filtered or unexported fields }
Context 上下文
func (Context) ContextValue ¶
ContextValue 获取ctx里的值,取出后根据写入的类型自行断言
func (Context) FormValues ¶ added in v0.4.1
FormValues 获取所有GET/POST参数值
func (Context) PostValues ¶ added in v0.4.1
PostValues 获取所有POST参数值
func (Context) QueryValue ¶
QueryValue 获取某个GET参数值
func (Context) QueryValues ¶ added in v0.4.1
QueryValues 获取所有GET参数值
func (Context) RawFormValue ¶ added in v0.4.1
RawFormValue 获取某个POST参数值的string类型
func (Context) RawQueryValue ¶ added in v0.4.1
RawQueryValue 获取某个GET参数值的string类型
func (Context) RawRouteValue ¶ added in v0.4.1
RawRouteValue 获取某个路由参数值的string类型
func (Context) RouteValues ¶ added in v0.4.1
func (ctx Context) RouteValues() []httprouter.Param
RouteValues 获取所有路由参数值
func (*Context) SetContextValue ¶
SetContextValue 在ctx里存储值,如果key存在则替换值
type Event ¶
type Event struct { Status int // HTTP状态码 Trace []string // 触发事件的trace Message error // 事件消息文本 ResponseWriter http.ResponseWriter Request *http.Request }
Event 事件结构
type MiddlewareHandler ¶ added in v0.4.0
MiddlewareHandler 中间件处理器
type ReqValue ¶
ReqValue 请求参数值
func (ReqValue) MustFloat32 ¶
MustFloat32 将参数值转为float32类型,如果出错或者校验失败则返回默认值
func (ReqValue) MustFloat64 ¶
MustFloat64 将参数值转为float64类型,如果出错或者校验失败则返回默认值
func (ReqValue) MustString ¶
MustString将参数值转为string,如果出错或者校验失败则返回默认值
func (ReqValue) MustUint32 ¶
MustUint32 将参数值转为uint32类型,如果出错或者校验失败则返回默认值
func (ReqValue) MustUint64 ¶
MustUint64 将参数值转为uint64类型,如果出错或者校验失败则返回默认值
type RouterGroup ¶
type RouterGroup struct {
// contains filtered or unexported fields
}
RouterGroup 路由组
func (*RouterGroup) DELETE ¶
func (r *RouterGroup) DELETE(path string, handler Handler, middlewareHandlers ...MiddlewareHandler)
DELETE 路由
func (*RouterGroup) FILE ¶
func (r *RouterGroup) FILE(url string, local string)
FILE 定义路由到文件,不支持路由组和中间件
func (*RouterGroup) GET ¶
func (r *RouterGroup) GET(path string, handler Handler, middlewareHandlers ...MiddlewareHandler)
GET 路由
func (*RouterGroup) GROUP ¶
func (r *RouterGroup) GROUP(path string, middlewareHandlers ...MiddlewareHandler) RouterGroup
GROUP 路由组
func (*RouterGroup) HEAD ¶
func (r *RouterGroup) HEAD(path string, handler Handler, middlewareHandlers ...MiddlewareHandler)
HEAD 路由
func (*RouterGroup) Handle ¶
func (r *RouterGroup) Handle(method string, path string, handler Handler, middlewareHandlers ...MiddlewareHandler)
Handle 路由
func (*RouterGroup) OPTIONS ¶
func (r *RouterGroup) OPTIONS(path string, handler Handler, middlewareHandlers ...MiddlewareHandler)
OPTIONS 路由
func (*RouterGroup) PATCH ¶
func (r *RouterGroup) PATCH(path string, handler Handler, middlewareHandlers ...MiddlewareHandler)
PATCH 路由
func (*RouterGroup) PATH ¶
func (r *RouterGroup) PATH(url string, local string, list bool)
PATH 定义路由到目录,不支持路由组和中间件
func (*RouterGroup) POST ¶
func (r *RouterGroup) POST(path string, handler Handler, middlewareHandlers ...MiddlewareHandler)
POST 路由
func (*RouterGroup) PUT ¶
func (r *RouterGroup) PUT(path string, handler Handler, middlewareHandlers ...MiddlewareHandler)
PUT 路由