Documentation ¶
Index ¶
- type Context
- func (ctx *Context) Deadline() (deadline time.Time, ok bool)
- func (ctx *Context) Done() <-chan struct{}
- func (ctx *Context) Err() error
- func (ctx *Context) GetRequest() *http.Request
- func (ctx *Context) GetRespStatusCode() int
- func (ctx *Context) GetResponse() http.ResponseWriter
- func (ctx *Context) Header(key, value string) Responser
- func (ctx *Context) Html(file string, obj interface{}) Responser
- func (ctx *Context) Json(obj interface{}) Responser
- func (ctx *Context) Redirect(path string) Responser
- func (ctx *Context) Render(tplName string, data any) error
- func (ctx *Context) SetCookie(key string, val string, maxAge int, path string, domain string, secure bool, ...) Responser
- func (ctx *Context) SetHeader(key string, val string) Responser
- func (ctx *Context) SetOkStatus() Responser
- func (ctx *Context) SetParams(params map[string]string)
- func (ctx *Context) SetRequest(req *http.Request)
- func (ctx *Context) SetRespData(data []byte)
- func (ctx *Context) SetStatus(code int) Responser
- func (ctx *Context) Text(format string, values ...interface{}) Responser
- func (ctx *Context) Value(key any) any
- func (ctx *Context) Xml(obj interface{}) Responser
- type Core
- func (c *Core) Any(path string, handler HandleFunc)
- func (c *Core) Delete(path string, handler HandleFunc)
- func (c *Core) FindRouteNodeByRequest(request *http.Request) (*matchNode, bool)
- func (c *Core) Get(path string, handler HandleFunc)
- func (c *Core) Group(prefix string) Grouper
- func (c *Core) Post(path string, handler HandleFunc)
- func (c *Core) Put(path string, handler HandleFunc)
- func (c *Core) ServeHTTP(writer http.ResponseWriter, request *http.Request)
- func (c *Core) Start(addr string) error
- func (c *Core) StartTLS(addr, certFile, keyFile string) error
- func (c *Core) Use(middlewares ...Middleware)
- func (c *Core) UsePath(method string, path string, mws ...Middleware)
- type CoreOption
- type GoTemplateEngine
- type Group
- func (g *Group) Any(path string, handler HandleFunc)
- func (g *Group) Delete(path string, handler HandleFunc)
- func (g *Group) Get(path string, handler HandleFunc)
- func (g *Group) Group(uri string) Grouper
- func (g *Group) Post(path string, handler HandleFunc)
- func (g *Group) Put(path string, handler HandleFunc)
- type Grouper
- type HandleFunc
- type Middleware
- type Responser
- type Server
- type TemplateEngine
- type Tree
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct { MatchedRoute string CustomValues map[string]any // 自定义数据 // ContextWithFallback enable fallback Context.Deadline(), Context.Done(), Context.Err() and Context.Value() // when Context.Request.Context() is not nil. ContextWithFallback bool // contains filtered or unexported fields }
func (*Context) GetRequest ¶
func (*Context) GetRespStatusCode ¶
func (*Context) GetResponse ¶
func (ctx *Context) GetResponse() http.ResponseWriter
func (*Context) Header ¶
Header 是set和del方法的缩写,主要是重新响应的header 如果 value == "", 执行`ctx.resp.Header().Set(key, value)` 否则执行 `ctx.resp.Header().Set(key, value)`
func (*Context) SetOkStatus ¶
func (*Context) SetRequest ¶
func (*Context) SetRespData ¶
type Core ¶
type Core struct {
// contains filtered or unexported fields
}
func NewCore ¶
func NewCore(opts ...CoreOption) *Core
func (*Core) Any ¶
func (c *Core) Any(path string, handler HandleFunc)
func (*Core) Delete ¶
func (c *Core) Delete(path string, handler HandleFunc)
func (*Core) FindRouteNodeByRequest ¶
匹配路由
func (*Core) Get ¶
func (c *Core) Get(path string, handler HandleFunc)
func (*Core) Post ¶
func (c *Core) Post(path string, handler HandleFunc)
func (*Core) Put ¶
func (c *Core) Put(path string, handler HandleFunc)
type CoreOption ¶
type CoreOption func(c *Core)
func CoreWithTemplateEngine ¶
func CoreWithTemplateEngine(tplEngine TemplateEngine) CoreOption
type GoTemplateEngine ¶
func (*GoTemplateEngine) ParseGlob ¶
func (g *GoTemplateEngine) ParseGlob(pattern string) error
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
func (*Group) Any ¶
func (g *Group) Any(path string, handler HandleFunc)
func (*Group) Delete ¶
func (g *Group) Delete(path string, handler HandleFunc)
func (*Group) Get ¶
func (g *Group) Get(path string, handler HandleFunc)
func (*Group) Post ¶
func (g *Group) Post(path string, handler HandleFunc)
func (*Group) Put ¶
func (g *Group) Put(path string, handler HandleFunc)
type Grouper ¶
type Grouper interface { Post(path string, handler HandleFunc) Put(path string, handler HandleFunc) Get(path string, handler HandleFunc) Delete(path string, handler HandleFunc) Any(path string, handler HandleFunc) // Group 实现嵌套 Group(string string) Grouper }
Grouper 前缀分组 实现HttpMethod方法
type HandleFunc ¶
type Middleware ¶
type Middleware func(handleFunc HandleFunc) HandleFunc
type Responser ¶
type Responser interface { // Json Json输出 Json(obj interface{}) Responser // Xml Xml输出 Xml(obj interface{}) Responser // Html Html输出 Html(template string, obj interface{}) Responser // Text string输出 Text(format string, values ...interface{}) Responser // Redirect 重定向 Redirect(path string) Responser // SetCookie 设置Cookie SetCookie(key string, val string, maxAge int, path, domain string, secure, httpOnly bool) Responser // SetStatus 设置状态码 SetStatus(code int) Responser // SetHeader 设置header SetHeader(key string, val string) Responser // SetOkStatus 设置200状态 SetOkStatus() Responser // Header header修订 Header(key, value string) Responser }
type TemplateEngine ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.