Documentation ¶
Index ¶
- func WriteError(w http.ResponseWriter, code int, err string)
- func WriteJSON(w http.ResponseWriter, v interface{}) error
- type Handle
- type Middleware
- type Params
- type Router
- func (r *Router) Delete(path, title string, fn Handle)
- func (r *Router) Get(path, title string, fn Handle)
- func (r *Router) Index() map[string]string
- func (r *Router) IndexHandler(w http.ResponseWriter, _ *http.Request, _ Params)
- func (r *Router) Options(path, title string, fn Handle)
- func (r *Router) Post(path, title string, fn Handle)
- func (r *Router) Put(path, title string, fn Handle)
- func (r *Router) Run(address string) error
- func (r *Router) RunTLS(addr, certFile, keyFile string) error
- func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (r *Router) Subrouter(path string) *Router
- func (r *Router) Use(middleware ...Middleware)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WriteError ¶
func WriteError(w http.ResponseWriter, code int, err string)
WriteError writes a string as JSON encoded error
func WriteJSON ¶
func WriteJSON(w http.ResponseWriter, v interface{}) error
WriteJSON writes the given interface as JSON or returns an error
Types ¶
type Handle ¶
type Handle func(http.ResponseWriter, *http.Request, Params)
Handle describes the function that should be used by handlers
type Middleware ¶
Middleware reprents a default middleware function
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router represents a router
func (*Router) IndexHandler ¶
IndexHandler writes the index of all GET methods to the ResponseWriter
func (*Router) ServeHTTP ¶ added in v1.0.3
func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)
ServeHTTP implements http.Handler
func (*Router) Use ¶
func (r *Router) Use(middleware ...Middleware)
Use adds middleware to the router
Click to show internal directories.
Click to hide internal directories.