Documentation ¶
Index ¶
- func WithEngineOptions(engine *Engine, opts ...EngineOption)
- type Context
- func (c *Context) Abort()
- func (c *Context) HTML(code int, tplName string, data any)
- func (c *Context) JSON(code int, data interface{})
- func (c *Context) Next()
- func (c *Context) Params(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, template string, value ...string)
- type Engine
- type EngineOption
- type GoTemplateEngine
- type H
- type HandlerFunc
- type RouterGroup
- func (group *RouterGroup) DELETE(pattern string, handlerFunc HandlerFunc)
- func (group *RouterGroup) GET(pattern string, handlerFunc HandlerFunc)
- func (group *RouterGroup) Group(prefix string) *RouterGroup
- func (group *RouterGroup) POST(pattern string, handlerFunc HandlerFunc)
- func (group *RouterGroup) PUT(pattern string, handlerFunc HandlerFunc)
- func (group *RouterGroup) Use(middlewares ...HandlerFunc)
- type StaticFile
- type TemplateEngine
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithEngineOptions ¶
func WithEngineOptions(engine *Engine, opts ...EngineOption)
Types ¶
type Context ¶
type Context struct { // 原始的请求和响应对象 Writer http.ResponseWriter Req *http.Request // 当此请求方式 Method string // 当此请求地址 URL string // contains filtered or unexported fields }
func NewContext ¶
func NewContext(w http.ResponseWriter, r *http.Request) *Context
type Engine ¶
type Engine struct { *RouterGroup // 路由组 T TemplateEngine // 模板引擎 // contains filtered or unexported fields }
type EngineOption ¶
type EngineOption func(engine *Engine)
type GoTemplateEngine ¶
type HandlerFunc ¶
type HandlerFunc func(ctx *Context)
HandlerFunc 视图函数签名
func Recovery ¶
func Recovery() HandlerFunc
type RouterGroup ¶
type RouterGroup struct {
// contains filtered or unexported fields
}
func (*RouterGroup) DELETE ¶
func (group *RouterGroup) DELETE(pattern string, handlerFunc HandlerFunc)
func (*RouterGroup) GET ¶
func (group *RouterGroup) GET(pattern string, handlerFunc HandlerFunc)
GET 外部衍生API,提供给用户使用,现在嫁接到RouterGroup上
func (*RouterGroup) Group ¶
func (group *RouterGroup) Group(prefix string) *RouterGroup
func (*RouterGroup) POST ¶
func (group *RouterGroup) POST(pattern string, handlerFunc HandlerFunc)
func (*RouterGroup) PUT ¶
func (group *RouterGroup) PUT(pattern string, handlerFunc HandlerFunc)
type StaticFile ¶
func NewStaticFile ¶
func NewStaticFile(dir string, path string) *StaticFile
func (*StaticFile) Handler ¶
func (s *StaticFile) Handler() HandlerFunc
type TemplateEngine ¶
type TemplateEngine interface { // Render 渲染页面方法 // ctx 上下文,可能需要从中拿取相应树 // tplName 模板名字 // data 需要填充到模板中的数据 // 返回值 []byte渲染后的模板数据 // 返回值 error错误信息 Render(ctx context.Context, tplName string, data any) ([]byte, error) }
TemplateEngine 模板引擎抽象
func NewGoTemplateEngine ¶
func NewGoTemplateEngine(t *template.Template) TemplateEngine
Source Files ¶
Click to show internal directories.
Click to hide internal directories.