router

package
v0.0.0-...-d1236c8 Latest Latest
Warning

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

Go to latest
Published: May 7, 2016 License: BSD-3-Clause Imports: 5 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler func(http.ResponseWriter, *http.Request) *HandlerError

type HandlerError

type HandlerError struct {
	Err     error
	Message string
	Code    int
}

HandlerError is a customized error type used to improve error reporting in handlers by including additional information to be sent back to the user

func NewHandlerError

func NewHandlerError(err error, message string, code int) *HandlerError

NewHandlerError initializes an HandlerError

func NewSimpleHandlerError

func NewSimpleHandlerError(message string, code int) *HandlerError

NewSimpleHandlerError initializes an HandlerError by first duplicating the error message into an error type using errors.New

func NewStringHandlerError

func NewStringHandlerError(err, message string, code int) *HandlerError

NewStringHandlerError initializes an HandlerError, but first converts the err string into an error type using errors.New

func (*HandlerError) Error

func (e *HandlerError) Error() string

type Router

type Router struct {
	*httprouter.Router
	// contains filtered or unexported fields
}

Router is a wrapper around julienschmidt/httprouter that implements error handling specific to this application.

func NewWithPrefix

func NewWithPrefix(prefix string) *Router

NewWithPrefix creates a Router that adds an option to use a common prefix for all the paths.

func (Router) DELETE

func (r Router) DELETE(path string, handler HandlerWithParams)

func (Router) GET

func (r Router) GET(path string, handler Handler)

func (Router) GETWithParams

func (r Router) GETWithParams(path string, handler HandlerWithParams)

func (Router) POST

func (r Router) POST(path string, handler Handler)

func (Router) POSTWithParams

func (r Router) POSTWithParams(path string, handler HandlerWithParams)

func (Router) PUT

func (r Router) PUT(path string, handler HandlerWithParams)

Jump to

Keyboard shortcuts

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