Documentation ¶
Overview ¶
Package ws profides utilities to create webservices. It is a lightweight framework around the stardard net/http and the httprouter libraries. It uses go.net/context to store values for the lifetime of a request. The design of the framework is based on this excellent article on web frameworks in go. http://nicolasmerouze.com/build-web-framework-golang/
Index ¶
- func Params(ctx context.Context) httprouter.Params
- type Handler
- type HandlerFunc
- type Middleware
- type MiddlewareGroup
- type Router
- func (r *Router) DELETE(path string, handle Handler)
- func (r *Router) GET(path string, handle Handler)
- func (r *Router) POST(path string, handle Handler)
- func (r *Router) PUT(path string, handle Handler)
- func (r *Router) ServeFiles(path string, root http.FileSystem)
- func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Handler ¶
Handler is an interface for processing an http request. Based on the standard http lib but with an additional context object.
type HandlerFunc ¶
HandlerFunc defines a handler function for a request.
func (HandlerFunc) ServeHTTP ¶
func (f HandlerFunc) ServeHTTP(ctx context.Context, w http.ResponseWriter, r *http.Request)
ServeHTTP allows the HandlerFunc to be used as an handler.
type Middleware ¶
Middleware is a function that implements additional functionnality for a handler.
type MiddlewareGroup ¶
type MiddlewareGroup struct {
// contains filtered or unexported fields
}
MiddlewareGroup allows simple chaining of middlewares. Based on alice (https://github.com/justinas/alice).
func NewMiddlewareGroup ¶
func NewMiddlewareGroup(handlers ...Middleware) MiddlewareGroup
NewMiddlewareGroup creates a new middleware group.
func (MiddlewareGroup) Append ¶
func (g MiddlewareGroup) Append(handlers ...Middleware) MiddlewareGroup
Append creates a new middleware group from an existing group.
func (MiddlewareGroup) Then ¶
func (g MiddlewareGroup) Then(handlerFunc HandlerFunc) Handler
Then returns a handler that executes the middleware chain then calls handler.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router handles routes for the application. It is a simple wrapper around the httprouter lib.
func (*Router) ServeFiles ¶
func (r *Router) ServeFiles(path string, root http.FileSystem)
ServeFiles serves files from the filesystem.