Documentation
¶
Index ¶
- type ActionFunc
- type BasicResponse
- type Context
- type DozeRoute
- func (r *DozeRoute) Actions() map[string]ActionFunc
- func (r *DozeRoute) And(method string, action ActionFunc) *DozeRoute
- func (r *DozeRoute) For(path string) *DozeRoute
- func (r *DozeRoute) Name() string
- func (r *DozeRoute) Named(name string) *DozeRoute
- func (r *DozeRoute) ParamNames() []string
- func (r *DozeRoute) ParamValues() []interface{}
- func (r *DozeRoute) Path() string
- func (r *DozeRoute) SetActions(actions map[string]ActionFunc)
- func (r *DozeRoute) SetName(name string)
- func (r *DozeRoute) SetParamNames(paramNames []string)
- func (r *DozeRoute) SetParamValues(paramValues []interface{})
- func (r *DozeRoute) SetPath(path string)
- func (r *DozeRoute) With(method string, action ActionFunc) *DozeRoute
- type GzipResponse
- type Handler
- type MiddlewareFunc
- type NextFunc
- type PatternedRoute
- type ResponseSender
- type ResponseWriter
- type RestRouter
- type Route
- type Routeable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActionFunc ¶
type ActionFunc func(*Context) ResponseSender
ActionFunc is a type that is a function to be used as a controller action
type BasicResponse ¶
BasicResponse contains all basic properties for a response
func NewCreatedJSONResponse ¶
func NewCreatedJSONResponse(body interface{}) BasicResponse
NewCreatedJSONResponse returns a BasicResponse tailored for JSON with status code of 201
func NewInternalServerErrorResponse ¶
func NewInternalServerErrorResponse() BasicResponse
NewInternalServerErrorResponse returns a BasicResponse defaulted for an internal server error
func NewNoContentResponse ¶
func NewNoContentResponse() BasicResponse
NewNoContentResponse returns a BasicResponse defaulted for no content
func NewNotFoundResponse ¶
func NewNotFoundResponse() BasicResponse
NewNotFoundResponse returns a BasicResponse defaulted for not found
func NewOKJSONResponse ¶
func NewOKJSONResponse(body interface{}) BasicResponse
NewOKJSONResponse returns a BasicResponse tailored for JSON with status code of 200
type Context ¶
type Context struct { Request *http.Request ResponseWriter *ResponseWriter Route PatternedRoute }
Context will contain all information about the current request scoped context
func (*Context) BindJSONEntity ¶
BindJSONEntity binds the JSON body from the request to an interface{}
type DozeRoute ¶
type DozeRoute struct {
// contains filtered or unexported fields
}
func (*DozeRoute) Actions ¶
func (r *DozeRoute) Actions() map[string]ActionFunc
func (*DozeRoute) ParamNames ¶
func (*DozeRoute) ParamValues ¶
func (r *DozeRoute) ParamValues() []interface{}
func (*DozeRoute) SetActions ¶
func (r *DozeRoute) SetActions(actions map[string]ActionFunc)
func (*DozeRoute) SetParamNames ¶
func (*DozeRoute) SetParamValues ¶
func (r *DozeRoute) SetParamValues(paramValues []interface{})
type GzipResponse ¶
type GzipResponse struct {
BasicResponse
}
GzipResponse is a wrapping response to gzip your BasicResponse
func NewGzipResponse ¶
func NewGzipResponse(br BasicResponse) GzipResponse
NewGzipResponse creates a new GzipResponse that wraps a BasicResponse that adds Content-Encoding to gzip
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler implements http.Handler and contains the router and controllers for the REST api
func NewHandler ¶
NewHandler returns a new Handler with router initialized
func (*Handler) Use ¶
func (h *Handler) Use(mf MiddlewareFunc)
Use applies a MiddlewareFunc to be executed in the request chain
type MiddlewareFunc ¶
MiddlewareFunc is a function type for adding middleware to the request
type NextFunc ¶
type NextFunc func(*Context)
NextFunc is a function type that progresses the middleware chain for the request
type PatternedRoute ¶
type PatternedRoute struct {
Route
}
func (PatternedRoute) Build ¶
func (r PatternedRoute) Build(m map[string]interface{}) (string, error)
Build returns the route path with route parameters replaced with values from the passed in map
func (PatternedRoute) Params ¶
func (r PatternedRoute) Params() map[string]interface{}
Params returns a key-value pair containing the route parameters defined in the route path. ParamNames should alwyas go 1-1 to the ParamValues, otherwise you will have a bad time
type ResponseSender ¶
ResponseSender is an interface to send response from ControllerActions
type ResponseWriter ¶
type ResponseWriter struct { http.ResponseWriter Size int StatusCode int }
ResponseWriter is a wrapper for http.ResponseWriter which includes extra properties to keep track of current response
func (*ResponseWriter) WriteHeader ¶
func (rw *ResponseWriter) WriteHeader(i int)
WriteHeader is overidding http.ResponseWriter in order to capture the StatusCode of the request
func (*ResponseWriter) Written ¶
func (rw *ResponseWriter) Written() bool
Written returns whether or not the current response has been written to
type RestRouter ¶
type RestRouter struct {
// contains filtered or unexported fields
}
func (RestRouter) Add ¶
func (ro RestRouter) Add(route Route)
func (RestRouter) Get ¶
func (ro RestRouter) Get(name string) PatternedRoute
func (RestRouter) Match ¶
func (ro RestRouter) Match(test string) (PatternedRoute, bool)
func (RestRouter) Prefix ¶
func (ro RestRouter) Prefix() string
func (RestRouter) SetPrefix ¶
func (ro RestRouter) SetPrefix(prefix string) RestRouter
type Route ¶
type Route interface { Name() string Path() string Actions() map[string]ActionFunc ParamNames() []string ParamValues() []interface{} SetName(string) SetPath(string) SetActions(map[string]ActionFunc) SetParamNames([]string) SetParamValues([]interface{}) }
type Routeable ¶
type Routeable interface { Get(string) PatternedRoute Match(string) (PatternedRoute, bool) }
Routeable is an interface which allows you to create your own router
- Get(string) *Route returns the route by route name
- Match(string) *Route takes a URI and returns a *Route it matches. If it does not it returns nil