Documentation ¶
Index ¶
- Constants
- Variables
- type A
- type Config
- type Context
- func (c *Context) BindJSON(v interface{}) error
- func (c *Context) Get(key string) (interface{}, bool)
- func (c *Context) Next()
- func (c *Context) RawRequest() interface{}
- func (c *Context) RawResponseWriter() interface{}
- func (c *Context) Set(key string, val interface{})
- func (c *Context) WriteBytes(code int, p []byte) error
- func (c *Context) WriteJSON(code int, v interface{}) error
- func (c *Context) WriteReader(code int, r io.Reader) error
- func (c *Context) WriteString(code int, s string) error
- type F
- type Group
- type HandlerFunc
- type Header
- type HeaderCodec
- type HeaderLengthEncoding
- type Option
- type Request
- type ResponseWriter
- type Router
Constants ¶
View Source
const ( XPath = "X-Path" XRealIP = "X-Real-IP" ContentType = "Content-Type" )
View Source
const ( MimeJson = "application/json; charset=utf-8" MimeStream = "application/octet-stream" )
Variables ¶
View Source
var ( JsonHandle = new(codec.JsonHandle) TextHeader = NewHeaderCodec(F{}, TextLengthEncoding, JsonHandle) BinaryHeader = NewHeaderCodec(F{}, BinaryLengthEncoding, JsonHandle) )
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct { // 请求 Request *Request // 响应写入器 Writer ResponseWriter // contains filtered or unexported fields }
Context 请求上下文
func NewContext ¶
func NewContext(request *Request, writer ResponseWriter) *Context
func (*Context) RawResponseWriter ¶
func (c *Context) RawResponseWriter() interface{}
RawResponseWriter 获取原生响应写入器
func (*Context) WriteBytes ¶
WriteBytes 写入字节流
func (*Context) WriteReader ¶
WriteReader 写入Reader
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group 路由组
func (*Group) Group ¶
func (c *Group) Group(prefix string, middlewares ...HandlerFunc) *Group
Group 创建子路由组
func (*Group) On ¶
func (c *Group) On(path string, handler HandlerFunc, middlewares ...HandlerFunc)
On 监听事件
type HeaderCodec ¶
type HeaderCodec struct {
// contains filtered or unexported fields
}
func NewHeaderCodec ¶
func NewHeaderCodec(template Header, lengthEncoding HeaderLengthEncoding, handle codec.Handle) *HeaderCodec
func (*HeaderCodec) NewHeader ¶
func (c *HeaderCodec) NewHeader() Header
type HeaderLengthEncoding ¶
type HeaderLengthEncoding uint8
const ( BinaryLengthEncoding HeaderLengthEncoding = 2 TextLengthEncoding HeaderLengthEncoding = 4 )
type ResponseWriter ¶
type ResponseWriter interface { Header() Header Write([]byte) (int, error) Code(code int) // Flush 刷新缓冲区 Flush() error // RawResponseWriter 获取原生响应写入器 RawResponseWriter() interface{} }
ResponseWriter 响应写入器
type Router ¶
type Router struct { HeaderCodec *HeaderCodec OnNoMatch HandlerFunc // contains filtered or unexported fields }
Router 路由器
func (*Router) Group ¶
func (c *Router) Group(prefix string, middlewares ...HandlerFunc) *Group
Group 创建路由组
func (*Router) On ¶
func (c *Router) On(path string, handler HandlerFunc, middlewares ...HandlerFunc)
On 监听事件
Source Files ¶
Click to show internal directories.
Click to hide internal directories.