http

package
v0.0.0-...-b7105a7 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2015 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FirstQueryVals

func FirstQueryVals(m url.Values) map[string]string

FirstQueryVals takes a url and returns a map taking only the first value of each query param sent

func WrapHandler

func WrapHandler(f interface{}, methods ...string) func(ResponseWriter, *Request)

wrapHandler takes a handler function and for each request, it rejects unaccepted methods, converts the query args to the function's args pointer and then validates those args.

If the method returns a non-nil error, then the error is returned if its an instance of PublicError, otherwise a generic "Internal Error" is sent back to the client. If a status code of 0 is returned, then if error is nil, a 500 is sent and otherwise a 200 is sent.

Types

type HTTPError

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

HTTPError implements the error interface but also optionally holds the HTTP status code for the appropriate error. If left to 0 the server should send 500

func NewError

func NewError(statusCode int, msg string, args ...interface{}) HTTPError

func (HTTPError) Code

func (e HTTPError) Code() int

func (HTTPError) Error

func (e HTTPError) Error() string

Jump to

Keyboard shortcuts

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