router

package
v0.0.0-...-50fae98 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2013 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const (
	CONNECT = "CONNECT"
	DELETE  = "DELETE"
	GET     = "GET"
	HEAD    = "HEAD"
	OPTIONS = "OPTIONS"
	PATCH   = "PATCH"
	POST    = "POST"
	PUT     = "PUT"
	TRACE   = "TRACE"
)

HTTP 1.1 Methods

Variables

This section is empty.

Functions

func ReadJSON

func ReadJSON(req *http.Request, v interface{}) error

ReadJSON parses JSON in the http.Request pointer stores the result in the value pointed to by v

func ReadXML

func ReadXML(req *http.Request, v interface{}) error

ReadXML parses req XML stores the result in the value pointed to by v

func ServeFormatted

func ServeFormatted(w http.ResponseWriter, req *http.Request, v interface{})

ServeFormatted parses req and serves as format specified in the Accept header

func ServeJSON

func ServeJSON(w http.ResponseWriter, v interface{})

func ServeXML

func ServeXML(w http.ResponseWriter, v interface{})

ServeXML serves req with XML repr of v

Types

type Router

type Router struct {
	// contains filtered or unexported fields
}

func New

func New() *Router

func (*Router) AddRoute

func (r *Router) AddRoute(method string, pattern string, handler http.HandlerFunc)

func (*Router) Del

func (r *Router) Del(pattern string, handler http.HandlerFunc)

func (*Router) Filter

func (r *Router) Filter(filter http.HandlerFunc)

func (*Router) FilterParam

func (r *Router) FilterParam(param string, filter http.HandlerFunc)

func (*Router) Get

func (r *Router) Get(pattern string, handler http.HandlerFunc)

Request-URI method implementations

func (*Router) Patch

func (r *Router) Patch(pattern string, handler http.HandlerFunc)

func (*Router) Post

func (r *Router) Post(pattern string, handler http.HandlerFunc)

func (*Router) Put

func (r *Router) Put(pattern string, handler http.HandlerFunc)

func (*Router) ServeHTTP

func (r *Router) ServeHTTP(rw http.ResponseWriter, req *http.Request)

required by http.Handler interface matches request with a route, and if found, serves the request with the route's handler

func (*Router) Static

func (r *Router) Static(pattern string, dir string)

single static file handler TODO: static dir handler

Jump to

Keyboard shortcuts

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