fweight

package module
v0.0.0-...-646a310 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 20, 2014 License: MIT Imports: 6 Imported by: 4

README

fweight

Framework Eight is a router and server for the Go language that focuses on speed and semantics.

Framework eight is currently alpha software: layer2 (the MIME management layer) is unfinished and the current API is subject to change.

In addition, some of the documentation is from previous revisions of the software.

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) Error

func (e Err) Error() string

func (Err) HTTPStatusCode

func (e Err) HTTPStatusCode() Status

type HTTPStatus

type HTTPStatus interface {
	HTTPStatusCode() Status
}

type Middleware

type Middleware interface {
	Middleware(http.Handler) http.Handler
}
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

type MiddlewareFunc func(http.Handler) http.Handler

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()

func (*Pipeline) ServeHTTP

func (p *Pipeline) ServeHTTP(rw http.ResponseWriter, rq *http.Request)

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
	StatusUnauthorized                 Status = 401
	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
	StatusServiceUnavailable      Status = 503
	StatusGatewayTimeout          Status = 504
	StatusHTTPVersionNotSupported Status = 505
)

func (Status) Err

func (s Status) Err() error

Returns an Err as the concrete value of an error interface, or nil.

func (Status) HTTPStatusCode

func (s Status) HTTPStatusCode() Status

func (Status) String

func (s Status) String() string

Function String returns the status text associated with this Status that would be returned by http.StatusText.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL