Documentation ¶
Overview ¶
Package http is an extra layer on to of the standard go net/http package.
This package does most of the heavy lifting for common http APIs, such as:
- Routing
- Request parsing
- Response rendering
- Graceful shutdown
- Basic security
- Logging
- Stats
- Tracing
Index ¶
Constants ¶
const ( StatusContinue = 100 StatusSwitchingProtocols = 101 StatusOK = 200 StatusCreated = 201 StatusAccepted = 202 StatusNonAuthoritativeInfo = 203 StatusNoContent = 204 StatusResetContent = 205 StatusPartialContent = 206 StatusMultipleChoices = 300 StatusMovedPermanently = 301 StatusFound = 302 StatusSeeOther = 303 StatusNotModified = 304 StatusUseProxy = 305 StatusTemporaryRedirect = 307 StatusBadRequest = 400 StatusPaymentRequired = 402 StatusForbidden = 403 StatusNotFound = 404 StatusMethodNotAllowed = 405 StatusNotAcceptable = 406 StatusProxyAuthRequired = 407 StatusRequestTimeout = 408 StatusConflict = 409 StatusGone = 410 StatusLengthRequired = 411 StatusPreconditionFailed = 412 StatusRequestEntityTooLarge = 413 StatusRequestURITooLong = 414 StatusUnsupportedMediaType = 415 StatusRequestedRangeNotSatisfiable = 416 StatusExpectationFailed = 417 StatusTeapot = 418 StatusInternalServerError = 500 StatusNotImplemented = 501 StatusBadGateway = 502 StatusGatewayTimeout = 504 StatusHTTPVersionNotSupported = 505 )
HTTP status codes, defined in RFC 2616.
const ( OPTIONS = "OPTIONS" GET = "GET" POST = "POST" PUT = "PUT" DELETE = "DELETE" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Action ¶
Action is an endpoint that handles incoming HTTP requests for a specific route. An action is stateless, self contained and should not share its context with other actions.
type Context ¶
type Context struct { Ctx journey.Ctx Res http.ResponseWriter Req *http.Request Parser Parser Params map[string]string StartAt time.Time // contains filtered or unexported fields }
Context holds the request context that is injected into an action
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler is a lego handler for the HTTP protocol
func (*Handler) Append ¶
func (h *Handler) Append(m Middleware)
Append appends the given middleware to the call chain
func (*Handler) Drain ¶
func (h *Handler) Drain()
Drain puts the handler into drain mode. All new requests will be blocked with a 503 and it will block this call until all in-flight requests have been completed
type Middleware ¶
Middleware is a function called on the HTTP stack before an action
type ParseJSON ¶
type ParseJSON struct {
// contains filtered or unexported fields
}
ParseJSON Parses JSON
type ParseNull ¶
type ParseNull struct {
// contains filtered or unexported fields
}
ParseNull is a null-object that is used when no other Parsers have been found
type RenderHead ¶
type RenderHead struct {
Code int
}
RenderHead is a renderer that returns a body-less response
func (*RenderHead) Encode ¶
func (r *RenderHead) Encode(ctx *Context) error
func (*RenderHead) Status ¶
func (r *RenderHead) Status() int
type RenderJSON ¶
type RenderJSON struct { Code int V interface{} }
RenderJSON is a renderer that marshal responses in JSON
func (*RenderJSON) Encode ¶
func (r *RenderJSON) Encode(ctx *Context) error
func (*RenderJSON) Status ¶
func (r *RenderJSON) Status() int
type RenderRedirect ¶
type RenderRedirect struct {
URL string
}
RenderRedirect is a renderer that returns a redirection
func (*RenderRedirect) Encode ¶
func (r *RenderRedirect) Encode(ctx *Context) error
func (*RenderRedirect) Status ¶
func (r *RenderRedirect) Status() int