Documentation
¶
Index ¶
- type Handler
- type HandlerResult
- type JSONRenderer
- type Metadata
- type Multiplexer
- type Renderer
- type RequestRuntime
- func (runtime *RequestRuntime) ContentType() string
- func (runtime *RequestRuntime) GetQueryParam(queryParam string) string
- func (runtime *RequestRuntime) HeaderValue(key string) string
- func (runtime *RequestRuntime) LogicError(message string) HandlerResult
- func (runtime *RequestRuntime) ReadBody(target interface{}) error
- func (runtime *RequestRuntime) ServerError() HandlerResult
- func (runtime *RequestRuntime) Websocket() (defs.Streamer, error)
- type ResultList
- type RouteConfig
- type RouteConfigMapMatcher
- type ServerRuntime
- type WebsocketUpgrader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler func(*RequestRuntime) HandlerResult
Handler much like http.HandlerFunc, these are used as "route" handlers by the ServerRuntime
type HandlerResult ¶
type HandlerResult struct { Errors []error Results ResultList Metadata map[string]interface{} Redirect string NoRender bool Status int }
HandlerResult public contract between routes and the server runtime for consistent rendering
type JSONRenderer ¶
type JSONRenderer struct {
// contains filtered or unexported fields
}
JSONRenderer exposes a `Renderer` interface for rendering `HandlerResult`s in json
func (*JSONRenderer) Render ¶
func (js *JSONRenderer) Render(response http.ResponseWriter, result HandlerResult) error
Render uses a response writer and a `HandlerResult` to serialize the result in a json-api like format
type Metadata ¶
type Metadata map[string]interface{}
Metadata is a basic string/interface map interface
type Multiplexer ¶
Multiplexer defines an interface that returns a handler, set of values and a boolean value indicating if a route has been found that matches the provided request.
type Renderer ¶
type Renderer interface {
Render(http.ResponseWriter, HandlerResult) error
}
Renderer defines the interface used by the `ServerRuntime` to render `HandlerResult`s returned by route handlers
type RequestRuntime ¶
type RequestRuntime struct { url.Values WebsocketUpgrader bg.ChannelPublisher *logging.Logger *http.Request // contains filtered or unexported fields }
RequestRuntime is used by the ServerRuntime to expose per-request packages of shared system interfaces
func (*RequestRuntime) ContentType ¶
func (runtime *RequestRuntime) ContentType() string
ContentType returns the request content type from the inbound request.
func (*RequestRuntime) GetQueryParam ¶
func (runtime *RequestRuntime) GetQueryParam(queryParam string) string
GetQueryParam returns a parsed url.Values struct from the request query params.
func (*RequestRuntime) HeaderValue ¶
func (runtime *RequestRuntime) HeaderValue(key string) string
HeaderValue returns value for the given header key.
func (*RequestRuntime) LogicError ¶
func (runtime *RequestRuntime) LogicError(message string) HandlerResult
LogicError will wrap the provided strin the appropriate error prefix and return a HandlerResult
func (*RequestRuntime) ReadBody ¶
func (runtime *RequestRuntime) ReadBody(target interface{}) error
ReadBody will attempt to fill the provided interface with values from the http request
func (*RequestRuntime) ServerError ¶
func (runtime *RequestRuntime) ServerError() HandlerResult
ServerError returns a HandlerResult w/ the standardized server error response text
type ResultList ¶
type ResultList interface{}
ResultList is the array of items returned by a handler that will be rendered in the
type RouteConfig ¶
RouteConfig defines a simple structure composed of the http method and a regular expression path matcher
type RouteConfigMapMatcher ¶
type RouteConfigMapMatcher map[RouteConfig]Handler
RouteConfigMapMatcher is simply a map between a route configuration and the handler function
func (*RouteConfigMapMatcher) MatchRequest ¶
MatchRequest implements the net.Multiplexer interface.
type ServerRuntime ¶
type ServerRuntime struct { WebsocketUpgrader Multiplexer bg.ChannelPublisher *logging.Logger ApplicationVersion string }
ServerRuntime defines the object that implments the http.Handler interface used during application startup to open the http server. It is also responsible for matching inbound requests with it's embedded routelist and creating the request runtime to be sent into the matching route handler.
func (*ServerRuntime) ServeHTTP ¶
func (runtime *ServerRuntime) ServeHTTP(responseWriter http.ResponseWriter, request *http.Request)
ServerHTTP implmentation of the http.Handler interface method