Documentation ¶
Index ¶
- Constants
- func ConfigureSwagger(apiDocPath string, container *restful.Container)
- func NewHTTPHandler() *restful.Container
- func NewPath(root, doc string) *restful.WebService
- func ParseRequestBody(r *restful.Request, o interface{}) error
- func UnsecuredHandler(handler EndpointFunction) restful.RouteFunction
- type Container
- type EndpointFunction
- type EndpointHandlerParams
- type Resp
- type RespError
Constants ¶
const ( // Alert should be corrected immediately e.g. Loss of the primary ISP connection. Alert = "alert" // Critical conditions e.g. A failure in the system's primary application. Critical = "crit" // Error conditions e.g. An application has exceeded its file storage limit and attempts to write are failing. Error = "err" // Warning may indicate that an error will occur if action is not taken. e.g. A non-root file system has only 2GB remaining. Warning = "warn" // Notice events that are unusual, but not error conditions. e.g. Ski Haus Delta reports temperature < low_notice(50) Notice = "notice" // Informational normal operational messages that require no action. e.g. An application has started, paused or ended successfully. Informational = "info" // Debug information useful to developers for debugging the application. Debug = "debug" )
Syslog model error severity levels https://en.wikipedia.org/wiki/Syslog#Severity_level
Variables ¶
This section is empty.
Functions ¶
func ConfigureSwagger ¶
ConfigureSwagger configures the swagger documentation for all endpoints in the container
func NewHTTPHandler ¶
NewHTTPHandler returns a new restful container
func NewPath ¶
func NewPath(root, doc string) *restful.WebService
NewPath returns a new API Path lie /api/something
func ParseRequestBody ¶
ParseRequestBody parses request body
func UnsecuredHandler ¶
func UnsecuredHandler(handler EndpointFunction) restful.RouteFunction
UnsecuredHandler is a handler for an open to the world endpoint
Types ¶
type Container ¶
type Container interface { Add(service *restful.WebService) *restful.Container RegisteredWebServices() []*restful.WebService }
Container interfaces *restful.Container, a web service container
type EndpointFunction ¶
type EndpointFunction func(*EndpointHandlerParams)
EndpointFunction is a function that intakes EndpointHandlerParams to respond to a RESTful call
type EndpointHandlerParams ¶
EndpointHandlerParams is a value passed to every function that is supposed to handle RESTful calls
type Resp ¶
type Resp struct { Links struct { Self string `json:"self"` } `json:"links"` Metadata struct { Generated string `json:"generated"` } `json:"metadata"` Errors []RespError `json:"errors"` }
Resp is the structure that will be in every API response
func (*Resp) AddDetailedError ¶
AddDetailedError adds a formatted REST error to response
func (*Resp) DecorateResponse ¶
DecorateResponse is executed before a response is generated