Documentation ¶
Index ¶
- type Context
- func (c *Context) Bytes(code int, b []byte) error
- func (c *Context) Get(key string) interface{}
- func (c *Context) JSON(code int, data interface{}) error
- func (c *Context) NoContent(code int) error
- func (c *Context) QueryParam(param string) string
- func (c *Context) RealIP() string
- func (c *Context) Redirect(code int, url string) error
- func (c *Context) Render(code int, template string, data interface{}) error
- func (c *Context) Set(key string, value interface{})
- func (c *Context) StatusText(code int) error
- func (c *Context) String(code int, s string) error
- type ErrorHandle
- type Group
- func (g *Group) DELETE(path string, handle Handle, middleware ...Middleware)
- func (g *Group) GET(path string, handle Handle, middleware ...Middleware)
- func (g *Group) Group(prefix string, middleware ...Middleware) *Group
- func (g *Group) HEAD(path string, handle Handle, middleware ...Middleware)
- func (g *Group) OPTIONS(path string, handle Handle, middleware ...Middleware)
- func (g *Group) PATCH(path string, handle interface{}, middleware ...Middleware)
- func (g *Group) POST(path string, handle interface{}, middleware ...Middleware)
- func (g *Group) PUT(path string, handle interface{}, middleware ...Middleware)
- type Handle
- type Middleware
- type Reader
- type Renderer
- type Router
- func (r *Router) DELETE(path string, handle Handle, middleware ...Middleware)
- func (r *Router) GET(path string, handle Handle, middleware ...Middleware)
- func (r *Router) Group(prefix string, middleware ...Middleware) *Group
- func (r *Router) HEAD(path string, handle Handle, middleware ...Middleware)
- func (r *Router) OPTIONS(path string, handle Handle, middleware ...Middleware)
- func (r *Router) PATCH(path string, handle interface{}, middleware ...Middleware)
- func (r *Router) POST(path string, handle interface{}, middleware ...Middleware)
- func (r *Router) PUT(path string, handle interface{}, middleware ...Middleware)
- func (r *Router) Start(addr string) error
- func (r *Router) StartTLS(addr, certFile, keyFile string, conf *tls.Config) error
- func (r *Router) Stop() error
- func (r *Router) Use(m ...Middleware)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct { Request *http.Request Response http.ResponseWriter Param func(string) string // contains filtered or unexported fields }
Context is passed to handlers and middlewares
func NewContext ¶ added in v0.1.5
func NewContext(router *Router, res http.ResponseWriter, req *http.Request, param httprouter.Params) *Context
NewContext creates a new context, this function is only exported for use in tests
func (*Context) NoContent ¶
NoContent returns the given status code without writing anything to the body
func (*Context) QueryParam ¶ added in v0.1.1
QueryParam returns the specified parameter from the query string. Returns an empty string if it doesn't exist. Returns the first parameter if multiple instances exist
func (*Context) RealIP ¶ added in v0.1.4
RealIP uses proxy headers for the real ip, if none exist the IP of the current connection is returned
func (*Context) StatusText ¶ added in v0.0.3
StatusText returns the given status code with the matching status text
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group is a router group with a shared prefix and set of middlewares
func (*Group) DELETE ¶
func (g *Group) DELETE(path string, handle Handle, middleware ...Middleware)
DELETE adds a DELETE route
func (*Group) GET ¶
func (g *Group) GET(path string, handle Handle, middleware ...Middleware)
GET adds a GET route
func (*Group) Group ¶
func (g *Group) Group(prefix string, middleware ...Middleware) *Group
Group creates a new router group with a shared prefix and set of middlewares
func (*Group) HEAD ¶
func (g *Group) HEAD(path string, handle Handle, middleware ...Middleware)
HEAD adds a HEAD route
func (*Group) OPTIONS ¶
func (g *Group) OPTIONS(path string, handle Handle, middleware ...Middleware)
OPTIONS adds a OPTIONS route
func (*Group) PATCH ¶
func (g *Group) PATCH(path string, handle interface{}, middleware ...Middleware)
PATCH adds a PATCH route
func (*Group) POST ¶
func (g *Group) POST(path string, handle interface{}, middleware ...Middleware)
POST adds a POST route
func (*Group) PUT ¶
func (g *Group) PUT(path string, handle interface{}, middleware ...Middleware)
PUT adds a PUT route
type Middleware ¶
Middleware is a function that runs before your route, it gets the next handler as a parameter
type Renderer ¶
type Renderer interface {
Render(w io.Writer, template string, data interface{}, c *Context) error
}
Renderer renders a template
type Router ¶
type Router struct { Reader Reader Renderer Renderer NotFoundHandler Handle MethodNotAllowedHandler Handle ErrorHandler ErrorHandle TrimTrailingSlashes bool // contains filtered or unexported fields }
Router is the router itself
func (*Router) DELETE ¶
func (r *Router) DELETE(path string, handle Handle, middleware ...Middleware)
DELETE adds a DELETE route
func (*Router) GET ¶
func (r *Router) GET(path string, handle Handle, middleware ...Middleware)
GET adds a GET route
func (*Router) Group ¶
func (r *Router) Group(prefix string, middleware ...Middleware) *Group
Group creates a new router group with a shared prefix and set of middlewares
func (*Router) HEAD ¶
func (r *Router) HEAD(path string, handle Handle, middleware ...Middleware)
HEAD adds a HEAD route
func (*Router) OPTIONS ¶
func (r *Router) OPTIONS(path string, handle Handle, middleware ...Middleware)
OPTIONS adds a OPTIONS route
func (*Router) PATCH ¶
func (r *Router) PATCH(path string, handle interface{}, middleware ...Middleware)
PATCH adds a PATCH route
func (*Router) POST ¶
func (r *Router) POST(path string, handle interface{}, middleware ...Middleware)
POST adds a POST route
func (*Router) PUT ¶
func (r *Router) PUT(path string, handle interface{}, middleware ...Middleware)
PUT adds a PUT route