Documentation
¶
Overview ¶
Index ¶
- Variables
- func GetAllParams(r *http.Request) paramsMapType
- func GetParam(r *http.Request, key string) string
- type App
- type Context
- func (c *Context) AsciiJSON(code int, obj interface{})
- func (c *Context) BindJSON(obj interface{}) error
- func (c *Context) Form(name string) string
- func (c *Context) JSON(code int, obj interface{})
- func (c *Context) Path(name string) string
- func (c *Context) PureJSON(code int, obj interface{})
- func (c *Context) Query(name string) string
- func (c *Context) Render(code int, r render.Render)
- func (c *Context) ShouldBindWith(obj interface{}, b binding.Binding) error
- func (c *Context) Status(code int)
- func (c *Context) Text(code int, format string, args ...interface{})
- type HandleFunc
- type MiddlewareType
- type Node
- type Param
- type Parameters
- type Params
- type ResponeWriter
- type Router
- func (r *Router) DELETE(path string, handle http.HandlerFunc)
- func (r *Router) DELETEAndName(path string, handle http.HandlerFunc, routeName string)
- func (r *Router) GET(path string, handle http.HandlerFunc)
- func (r *Router) GETAndName(path string, handle http.HandlerFunc, routeName string)
- func (r *Router) Generate(method string, routeName string, params map[string]string) (string, error)
- func (r *Router) Group(prefix string) *Router
- func (r *Router) Handle(method string, path string, handle http.HandlerFunc)
- func (r *Router) HandleNotFound(w http.ResponseWriter, req *http.Request, middleware []MiddlewareType)
- func (r *Router) Match(requestUrl string, path string) bool
- func (r *Router) NotFoundFunc(handler http.HandlerFunc)
- func (r *Router) PATCH(path string, handle http.HandlerFunc)
- func (r *Router) PATCHAndName(path string, handle http.HandlerFunc, routeName string)
- func (r *Router) POST(path string, handle http.HandlerFunc)
- func (r *Router) POSTAndName(path string, handle http.HandlerFunc, routeName string)
- func (r *Router) PUT(path string, handle http.HandlerFunc)
- func (r *Router) PUTAndName(path string, handle http.HandlerFunc, routeName string)
- func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (r *Router) Use(middleware ...MiddlewareType)
- type RouterGroup
- func (e *RouterGroup) Delete(path string, h HandleFunc)
- func (e *RouterGroup) Get(path string, h HandleFunc)
- func (rg *RouterGroup) NewGroupRouter(group string) *RouterGroup
- func (e *RouterGroup) Patch(path string, h HandleFunc)
- func (e *RouterGroup) Post(path string, h HandleFunc)
- func (e *RouterGroup) Put(path string, h HandleFunc)
- func (e *RouterGroup) ServeHTTP(w http.ResponseWriter, r *http.Request)
- type Tree
Constants ¶
This section is empty.
Variables ¶
var ( // ErrGenerateParameters is returned when generating a route with wrong parameters. ErrGenerateParameters = errors.New("params contains wrong parameters") // ErrNotFoundRoute is returned when generating a route that can not find route in tree. ErrNotFoundRoute = errors.New("cannot find route in tree") // ErrNotFoundMethod is returned when generating a route that can not find method in tree. ErrNotFoundMethod = errors.New("cannot find method in tree") // ErrPatternGrammar is returned when generating a route that pattern grammar error. ErrPatternGrammar = errors.New("pattern grammar error") )
var (
MULTI_FORM = "multipart/form-data"
)
Functions ¶
func GetAllParams ¶
GetAllParams returns all route params stored in http.Request.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
func (*App) Group ¶
func (e *App) Group(group string) *RouterGroup
func (*App) Router ¶
func (e *App) Router() *RouterGroup
type Context ¶
func (*Context) AsciiJSON ¶
AsciiJSON serializes the given struct as JSON into the response body with unicode to ASCII string. It also sets the Content-Type as "application/json".
func (*Context) JSON ¶
JSON serializes the given struct as JSON into the response body. It also sets the Content-Type as "application/json".
func (*Context) PureJSON ¶
PureJSON serializes the given struct as JSON into the response body. PureJSON, unlike JSON, does not replace special html characters with their unicode entities.
func (*Context) ShouldBindWith ¶
bing
type HandleFunc ¶
type HandleFunc func(ctx *Context)
type MiddlewareType ¶
type MiddlewareType func(next http.HandlerFunc) http.HandlerFunc
MiddlewareType is a public type that is used for middleware
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node records any URL params, and executes an end handler.
type Parameters ¶
type Parameters struct {
// contains filtered or unexported fields
}
Parameters records some parameters
type ResponeWriter ¶
type ResponeWriter struct {
http.ResponseWriter
// contains filtered or unexported fields
}
func (*ResponeWriter) Size ¶
func (w *ResponeWriter) Size() int
func (*ResponeWriter) Status ¶
func (w *ResponeWriter) Status() int
func (*ResponeWriter) WriteHeaderNow ¶
func (w *ResponeWriter) WriteHeaderNow(code int)
func (*ResponeWriter) Written ¶
func (w *ResponeWriter) Written() bool
type Router ¶
type Router struct {
// PanicHandler for handling panic.
PanicHandler func(w http.ResponseWriter, req *http.Request, err interface{})
// contains filtered or unexported fields
}
Router is a simple HTTP route multiplexer that parses a request path, records any URL params, and executes an end handler.
func NewRouter ¶
func NewRouter() *Router
New returns a newly initialized Router object that implements the Router
func (*Router) DELETE ¶
func (r *Router) DELETE(path string, handle http.HandlerFunc)
DELETE adds the route `path` that matches a DELETE http method to execute the `handle` http.HandlerFunc.
func (*Router) DELETEAndName ¶
func (r *Router) DELETEAndName(path string, handle http.HandlerFunc, routeName string)
DELETEAndName is short for `DELETE` and Named routeName
func (*Router) GET ¶
func (r *Router) GET(path string, handle http.HandlerFunc)
GET adds the route `path` that matches a GET http method to execute the `handle` http.HandlerFunc.
func (*Router) GETAndName ¶
func (r *Router) GETAndName(path string, handle http.HandlerFunc, routeName string)
GETAndName is short for `GET` and Named routeName
func (*Router) Generate ¶
func (r *Router) Generate(method string, routeName string, params map[string]string) (string, error)
Generate returns reverse routing by method, routeName and params
func (*Router) Handle ¶
func (r *Router) Handle(method string, path string, handle http.HandlerFunc)
Handle registers a new request handler with the given path and method.
func (*Router) HandleNotFound ¶
func (r *Router) HandleNotFound(w http.ResponseWriter, req *http.Request, middleware []MiddlewareType)
HandleNotFound registers a handler when the request route is not found
func (*Router) NotFoundFunc ¶
func (r *Router) NotFoundFunc(handler http.HandlerFunc)
NotFoundFunc registers a handler when the request route is not found
func (*Router) PATCH ¶
func (r *Router) PATCH(path string, handle http.HandlerFunc)
PATCH adds the route `path` that matches a PATCH http method to execute the `handle` http.HandlerFunc.
func (*Router) PATCHAndName ¶
func (r *Router) PATCHAndName(path string, handle http.HandlerFunc, routeName string)
PATCHAndName is short for `PATCH` and Named routeName
func (*Router) POST ¶
func (r *Router) POST(path string, handle http.HandlerFunc)
POST adds the route `path` that matches a POST http method to execute the `handle` http.HandlerFunc.
func (*Router) POSTAndName ¶
func (r *Router) POSTAndName(path string, handle http.HandlerFunc, routeName string)
POSTAndName is short for `POST` and Named routeName
func (*Router) PUT ¶
func (r *Router) PUT(path string, handle http.HandlerFunc)
PUT adds the route `path` that matches a PUT http method to execute the `handle` http.HandlerFunc.
func (*Router) PUTAndName ¶
func (r *Router) PUTAndName(path string, handle http.HandlerFunc, routeName string)
PUTAndName is short for `PUT` and Named routeName
func (*Router) ServeHTTP ¶
func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)
ServeHTTP makes the router implement the http.Handler interface.
func (*Router) Use ¶
func (r *Router) Use(middleware ...MiddlewareType)
Use appends a middleware handler to the middleware stack.
type RouterGroup ¶
type RouterGroup struct {
// contains filtered or unexported fields
}
func DefautlRouter ¶
func DefautlRouter() *RouterGroup
func (*RouterGroup) Delete ¶
func (e *RouterGroup) Delete(path string, h HandleFunc)
func (*RouterGroup) Get ¶
func (e *RouterGroup) Get(path string, h HandleFunc)
func (*RouterGroup) NewGroupRouter ¶
func (rg *RouterGroup) NewGroupRouter(group string) *RouterGroup
func (*RouterGroup) Patch ¶
func (e *RouterGroup) Patch(path string, h HandleFunc)
func (*RouterGroup) Post ¶
func (e *RouterGroup) Post(path string, h HandleFunc)
func (*RouterGroup) Put ¶
func (e *RouterGroup) Put(path string, h HandleFunc)
func (*RouterGroup) ServeHTTP ¶
func (e *RouterGroup) ServeHTTP(w http.ResponseWriter, r *http.Request)
type Tree ¶
type Tree struct {
// contains filtered or unexported fields
}
Tree records node
func NewTree ¶
func NewTree() *Tree
NewTree returns a newly initialized Tree object that implements the Tree
func (*Tree) Add ¶
func (t *Tree) Add(pattern string, handle http.HandlerFunc, middleware ...MiddlewareType)
Add use `pattern` 、handle、middleware stack as node register to tree
Directories
¶
| Path | Synopsis |
|---|---|
|
Package sqlx provides general purpose extensions to database/sql.
|
Package sqlx provides general purpose extensions to database/sql. |
|
reflectx
Package reflectx implements extensions to the standard reflect lib suitable for implementing marshalling and unmarshalling packages.
|
Package reflectx implements extensions to the standard reflect lib suitable for implementing marshalling and unmarshalling packages. |