muxer

package
v0.0.0-...-db96a77 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2016 License: MIT, MIT Imports: 4 Imported by: 0

README

muxer
=====

Muxer is a basic extension to build server (mainly request/response) on top of gorilla mux.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler func(Response, *Request)

func (Handler) ServeHTTP

func (h Handler) ServeHTTP(w http.ResponseWriter, req *http.Request)

type Request

type Request struct {
	Request     *http.Request
	Params      map[string]string
	QueryString map[string]string
}

func NewRequest

func NewRequest(req *http.Request) *Request

func (*Request) CurrentRoute

func (r *Request) CurrentRoute() *mux.Route

CurrentRoute allows to retrieve the current from a request

func (*Request) GetHost

func (r *Request) GetHost() string

func (*Request) IsAjax

func (r *Request) IsAjax() bool

type Response

type Response struct {
	http.ResponseWriter
}

func NewResponse

func NewResponse(res http.ResponseWriter) Response

func (*Response) Abort

func (r *Response) Abort(status int, body string)

Abort is a helper method that sends an HTTP header and an optional body. It is useful for returning 4xx or 5xx errors. Once it has been called, any return value from the handler will not be written to the response.

func (*Response) BadRequest

func (r *Response) BadRequest()

BadRequest writes a 400 HTTP response

func (*Response) ContentType

func (r *Response) ContentType(val string) string

ContentType sets the Content-Type header for an HTTP response. For example, ctx.ContentType("json") sets the content-type to "application/json" If the supplied value contains a slash (/) it is set as the Content-Type verbatim. The return value is the content type as it was set, or an empty string if none was found.

func (*Response) Forbidden

func (r *Response) Forbidden()

Forbidden writes a 403 HTTP response

func (*Response) NotAllowed

func (r *Response) NotAllowed()

NotAllowed writes a 405 HTTP response

func (*Response) NotFound

func (r *Response) NotFound(message string)

NotFound writes a 404 HTTP response

func (*Response) NotModified

func (r *Response) NotModified()

Notmodified writes a 304 HTTP response

func (*Response) Ok

func (r *Response) Ok(message string)

NotFound writes a 200 HTTP response

func (*Response) PermanentRedirect

func (r *Response) PermanentRedirect(url string)

PermanentRedirect is a helper method for 301 redirect

func (*Response) Redirect

func (r *Response) Redirect(status int, url_ string)

Redirect is a helper method for 3xx redirects.

func (*Response) SetHeader

func (r *Response) SetHeader(hdr string, val string, unique bool)

SetHeader sets a response header. If `unique` is true, the current value of that header will be overwritten . If false, it will be appended.

func (*Response) SetHeaders

func (r *Response) SetHeaders(headers map[string]string, unique bool)

SetHeaders sets response headers. If `unique` is true, the current value of that header will be overwritten . If false, it will be appended.

func (*Response) Unauthorized

func (r *Response) Unauthorized()

Unauthorized writes a 401 HTTP response

func (*Response) WriteString

func (r *Response) WriteString(content string)

WriteString writes string data into the response object.

Jump to

Keyboard shortcuts

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