Documentation ¶
Overview ¶
Framework Eight is an HTTP framework for go, focusing on speed, semantics and a modular interface for common web functions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Modified ¶
func Modified(w interface { Header() http.Header WriteHeader(int) }, r *http.Request, lastModified time.Time) (modified bool)
Functin Modified is a more general implement of net/http's ServeContent. Modifed handles If-Modified-Since requests. ETag, Content-Range and the rest can be handled by a Middleware. A zero lastModified is assumed to mean not modified.
func Redirect ¶
func Redirect(w interface { Header() http.Header WriteHeader(int) }, r *http.Request, urlStr string, code int)
Redirect replies to the request with a redirect to url, which may be a path relative to the request path. This function is more generic than the net/http implementation, but is functionally identical.
Types ¶
type Err ¶
type Err Status
Type Err represents an HTTP error code (Status > 400).
func (Err) HTTPStatusCode ¶
type HTTPStatus ¶
type HTTPStatus interface {
HTTPStatusCode() Status
}
type Middleware ¶
var DotContent Middleware = MiddlewareFunc(func(h http.Handler) http.Handler { const ctt = "Accept" return http.HandlerFunc(func(rw http.ResponseWriter, rq *http.Request) { defer h.ServeHTTP(rw, rq) ext := path.Ext(rq.URL.Path) if ext == "" { return } typ := mime.TypeByExtension(ext) if typ == "" { return } rq.URL.Path = strings.TrimRight(rq.URL.Path, ext) if v, ok := rq.Header[ctt]; ok && (len(v) > 0) { rq.Header[ctt][0] = strings.TrimRight(typ+rq.Header[ctt][0], ",") return } rq.Header[ctt] = []string{ typ, } }) })
DotContent implements a http.Handler that provides a middleware that adds the extension's media type to the ContentType of the request, and removes the extension.
This is not needed for the object package, it does this as part of the processing of the request, instead use the IgnoreExtensions Router.
type MiddlewareFunc ¶
func (MiddlewareFunc) Middleware ¶
func (m MiddlewareFunc) Middleware(h http.Handler) http.Handler
type Pipeline ¶
type Pipeline struct { Base http.Handler //Middleware is excecuted in slice order. Middleware []Middleware // contains filtered or unexported fields }
A Pipeline represents an http.Handler wrapped by a series of Middlewares.
The resultant http.Handler is lazily computed, but can be (re)computed with the ReloadMiddleware function.
func (*Pipeline) ReloadMiddleware ¶
func (p *Pipeline) ReloadMiddleware()
type Status ¶
type Status uint16
const ( StatusContinue Status = 100 StatusSwitchingProtocols Status = 101 StatusOK Status = 200 StatusCreated Status = 201 StatusAccepted Status = 202 StatusNonAuthoritativeInfo Status = 203 StatusNoContent Status = 204 StatusResetContent Status = 205 StatusPartialContent Status = 206 StatusMultipleChoices Status = 300 StatusMovedPermanently Status = 301 StatusFound Status = 302 StatusSeeOther Status = 303 StatusNotModified Status = 304 StatusUseProxy Status = 305 StatusTemporaryRedirect Status = 307 StatusBadRequest Status = 400 StatusPaymentRequired Status = 402 StatusForbidden Status = 403 StatusNotFound Status = 404 StatusMethodNotAllowed Status = 405 StatusNotAcceptable Status = 406 StatusProxyAuthRequired Status = 407 StatusRequestTimeout Status = 408 StatusConflict Status = 409 StatusGone Status = 410 StatusLengthRequired Status = 411 StatusPreconditionFailed Status = 412 StatusRequestEntityTooLarge Status = 413 StatusRequestURITooLong Status = 414 StatusUnsupportedMediaType Status = 415 StatusRequestedRangeNotSatisfiable Status = 416 StatusExpectationFailed Status = 417 StatusTeapot Status = 418 StatusInternalServerError Status = 500 StatusNotImplemented Status = 501 StatusBadGateway Status = 502 StatusGatewayTimeout Status = 504 StatusHTTPVersionNotSupported Status = 505 )
func (Status) HTTPStatusCode ¶
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package csp implments Content-Security-Policy, a HTTP header designed to mitigate XSS attacks.
|
Package csp implments Content-Security-Policy, a HTTP header designed to mitigate XSS attacks. |
goval
Package goval exposes functions to return strings containing a roundabout type declaration for passed interfaces.
|
Package goval exposes functions to return strings containing a roundabout type declaration for passed interfaces. |
Package resource provides some boilerplate code for serving static resources.
|
Package resource provides some boilerplate code for serving static resources. |