Http

func ResolveContentType

func ResolveContentType(req *http.Request) string

Get the content type. e.g. From "multipart/form-data; boundary=--" to "multipart/form-data" If none is specified, returns "text/html" by default.

func ResolveFormat

func ResolveFormat(req *http.Request) string

Resolve the accept request header.

type AcceptLanguage

type AcceptLanguage struct {
    Language string
    Quality  float32
}

A single language from the Accept-Language HTTP header.

type AcceptLanguages

type AcceptLanguages []AcceptLanguage

A collection of sortable AcceptLanguage instances.

func ResolveAcceptLanguage

func ResolveAcceptLanguage(req *http.Request) AcceptLanguages

Resolve the Accept-Language header value.

The results are sorted using the quality defined in the header for each language range with the most qualified language range as the first element in the slice.

See the HTTP header fields specification (http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4) for more details.

func (AcceptLanguages) Len

func (al AcceptLanguages) Len() int

func (AcceptLanguages) Less

func (al AcceptLanguages) Less(i, j int) bool

func (AcceptLanguages) String

func (al AcceptLanguages) String() string

func (AcceptLanguages) Swap

func (al AcceptLanguages) Swap(i, j int)

type Request

type Request struct {
    *http.Request
    ContentType     string
    Format          string // "html", "xml", "json", or "txt"
    AcceptLanguages AcceptLanguages
    Locale          string
    Websocket       *websocket.Conn
}

func NewRequest

func NewRequest(r *http.Request) *Request

type Response

type Response struct {
    Status      int
    ContentType string

    Out http.ResponseWriter
}

func NewResponse

func NewResponse(w http.ResponseWriter) *Response

func (*Response) WriteHeader

func (resp *Response) WriteHeader(defaultStatusCode int, defaultContentType string)

Write the header (for now, just the status code). The status may be set directly by the application (c.Response.Status = 501). if it isn't, then fall back to the provided status code.