Documentation ¶
Index ¶
- type Context
- type DefaultResponse
- type Middleware
- type Router
- func (r *Router) DELETE(path string, mid ...Middleware)
- func (r *Router) GET(path string, mid ...Middleware)
- func (r *Router) POST(path string, mid ...Middleware)
- func (r *Router) PUT(path string, mid ...Middleware)
- func (r *Router) Register(method string, path string, mid ...Middleware)
- func (r *Router) Run(address string) error
- func (r *Router) RunTLS(address string, cert string, key string) error
- func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)
- 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 { Response http.ResponseWriter Request *http.Request Params httprouter.Params Data map[string]interface{} Status int // contains filtered or unexported fields }
Context is the main struct that is used to pass information between different levels of the middleware
func NewContext ¶
func NewContext(w http.ResponseWriter, r *http.Request, p httprouter.Params, mid []Middleware) *Context
NewContext populates a context struct with the given data and returns it
func (*Context) Fail ¶
Fail aborts the context middleware execution and then writes the given code and message to the response.
func (*Context) Next ¶
func (c *Context) Next()
Next allows the context to continue on to the next level of the middleware. Note that each level of the middleware can call c.Next() whenever they would like and then the middleware will go on to finish the chain before completing the code past the c.Next() call
type DefaultResponse ¶
type DefaultResponse struct { Status string `json:"status"` Data interface{} `json:"data"` }
DefaultResponse is a default response object given for convenience to the user if a simplified struct is desired for return
type Middleware ¶
type Middleware func(*Context)
The Middleware type is any function that a *Context
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router represents the eden router
func (*Router) DELETE ¶
func (r *Router) DELETE(path string, mid ...Middleware)
DELETE is an alias for router.Register("DELETE", path, middleware)
func (*Router) GET ¶
func (r *Router) GET(path string, mid ...Middleware)
GET is an alias for router.Register("GET", path, middleware)
func (*Router) POST ¶
func (r *Router) POST(path string, mid ...Middleware)
POST is an alias for router.Register("POST", path, middleware)
func (*Router) PUT ¶
func (r *Router) PUT(path string, mid ...Middleware)
PUT is an alias for router.Register("PUT", path, middleware)
func (*Router) Register ¶
func (r *Router) Register(method string, path string, mid ...Middleware)
Register registeres a given method, path, and middleware to the httprouter for handling
func (*Router) RunTLS ¶
RunTLS runs a TLS server listening on the given address with the given cert and key
func (*Router) ServeHTTP ¶
func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)
ServeHTTP calls the httprouter.ServeHTTP and implements router as an http.Handler
func (*Router) Use ¶
func (r *Router) Use(m ...Middleware)
Use appends the given middleware to the router's middleware.