Documentation
¶
Index ¶
- type Context
- func (c *Context) Data(code int, data []byte)
- func (c *Context) Fail(code int, err string)
- func (c *Context) HTML(code int, name string, data interface{})
- func (c *Context) JSON(code int, obj interface{})
- func (c *Context) Next()
- func (c *Context) Param(key string) string
- func (c *Context) PostForm(key string) string
- func (c *Context) Query(key string) string
- func (c *Context) SetHeader(key string, value string)
- func (c *Context) Status(code int)
- func (c *Context) String(code int, format string, values ...interface{})
- type Engine
- type H
- type HandlerFunc
- type RouterGroup
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Engine ¶
type Engine struct { *RouterGroup // 支持 RouterGroup 的所有接口 // contains filtered or unexported fields }
Engine 协调整个框架的资源。 router 作为核心,不直接对外暴露接口,而是对外提供 Engine 模型
func (*Engine) LoadHTMLGlob ¶
LoadHTMLGlob 将所有模板加载到内存 注意需要先设置 FuncMap
func (*Engine) ServeHTTP ¶
func (e *Engine) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP 处理请求时,将 Writer 和 Req 封装为 Context 实例 1. 根据 URL 解析分组中间件 2. 由 Router 实现具体路由
func (*Engine) SetFuncMap ¶
type HandlerFunc ¶
type HandlerFunc func(*Context)
func Logger ¶
func Logger() HandlerFunc
func Recovery ¶
func Recovery() HandlerFunc
type RouterGroup ¶
type RouterGroup struct {
// contains filtered or unexported fields
}
保存 Path 前缀,以前缀划分分组,支持嵌套
func (*RouterGroup) GET ¶
func (rg *RouterGroup) GET(pattern string, handler HandlerFunc)
func (*RouterGroup) Group ¶
func (rg *RouterGroup) Group(name string) *RouterGroup
Group 创建分组,支持嵌套创建
func (*RouterGroup) POST ¶
func (rg *RouterGroup) POST(pattern string, handler HandlerFunc)
func (*RouterGroup) Static ¶
func (rg *RouterGroup) Static(relativeDir, rootDir string)
Static 绑定静态资源目录。使用 http.FileServer 完成静态文件服务
func (*RouterGroup) Use ¶
func (rg *RouterGroup) Use(middlewares ...HandlerFunc)
Click to show internal directories.
Click to hide internal directories.