Documentation
¶
Index ¶
- type Context
- func (c *Context) Abort()
- func (c *Context) AbortWithError(err error)
- func (c *Context) AbortWithJSON(code int, obj any)
- func (c *Context) AbortWithStatus(code int)
- func (c *Context) Aborted() bool
- func (c *Context) Context() context.Context
- func (c *Context) Get(key string) (value any, exists bool)
- func (c *Context) JSON(code int, obj any)
- func (c *Context) Next()
- func (c *Context) Param(name string) string
- func (c *Context) Render(code int, r Render)
- func (c *Context) Route() Route
- func (c *Context) Set(key string, value any)
- func (c *Context) Status(code int)
- func (c *Context) String(code int, s string)
- func (c *Context) UseContext(ctx context.Context)
- type Engine
- type ErrorHandler
- type HandlerFunc
- type HandlersChain
- type Param
- type Params
- type Render
- type ResponseWriter
- type Route
- type Router
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct {
Request *http.Request
Writer ResponseWriter
Params Params
Keys map[string]any
// contains filtered or unexported fields
}
func (*Context) AbortWithError ¶ added in v0.0.6
func (*Context) AbortWithJSON ¶
func (*Context) AbortWithStatus ¶
func (*Context) UseContext ¶ added in v0.0.7
UseContext 使用指定的上下文处理当前请求。 后续中间件和处理函数将使用新的上下文。
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func (*Engine) HandleError ¶
func (e *Engine) HandleError(handler ErrorHandler)
func (*Engine) NoRoute ¶
func (e *Engine) NoRoute(handlers ...HandlerFunc)
func (*Engine) ServeHTTP ¶
func (e *Engine) ServeHTTP(writer http.ResponseWriter, request *http.Request)
func (*Engine) Use ¶
func (e *Engine) Use(middleware ...HandlerFunc)
type ErrorHandler ¶
type HandlerFunc ¶
type HandlerFunc func(c *Context)
func Logger ¶ added in v0.0.6
func Logger() HandlerFunc
type HandlersChain ¶
type HandlersChain []HandlerFunc
func CombineHandlers ¶ added in v0.0.6
func CombineHandlers(base HandlersChain, handlers ...HandlerFunc) HandlersChain
type Param ¶ added in v0.0.6
type Param struct {
// Key 是规则中声明的参数名,不包含前缀的 : 或 *。
Key string
// Value 是输入路径中被该参数捕获到的原始字符串。
Value string
}
Param 是一次路径匹配得到的单个参数。
type Params ¶ added in v0.0.6
type Params []Param
Params 是按规则中参数出现顺序保存的参数列表。
type ResponseWriter ¶
type ResponseWriter interface {
http.ResponseWriter
http.Hijacker
http.Flusher
// Status returns the HTTP response status code of the current request.
Status() int
// Size returns the number of bytes already written into the response http body.
// See Written()
Size() int
// WriteString writes the string into the response body.
WriteString(string) (int, error)
// Written returns true if the response body was already written.
Written() bool
// WriteHeaderNow forces to write the http header (status code + headers).
WriteHeaderNow()
// Pusher get the http.Pusher for server push
Pusher() http.Pusher
}
ResponseWriter ...
type Route ¶
type Route interface {
Path() string
Handlers() HandlersChain
}
Route 表示 Router 已经匹配到的处理目标。
Source Files
¶
Click to show internal directories.
Click to hide internal directories.