wrapstesting

package
v0.0.0-...-ecd2d5e Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2014 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HTTP1_1 = http1_1{}
View Source
var ResponseWriterHandler wrap.Wrapper = responseWriterHandle{}

Functions

func Defer

func Defer(h http.Handler) wrap.Wrapper

func DeferFunc

func DeferFunc(fn func(http.ResponseWriter, *http.Request)) wrap.Wrapper

func Generator

func Generator(gen Generater) wrap.Wrapper

func GeneratorFunc

func GeneratorFunc(fn func(w http.ResponseWriter, r *http.Request) http.ResponseWriter) wrap.Wrapper

func HandlerMethod

func HandlerMethod(fn interface{}) http.Handler

func Json

func Json(t interface{}) wrap.Wrapper

func LOGGER

func LOGGER(prefix string) wrap.Wrapper

func Logger

func Logger(l *log.Logger) wrap.Wrapper

func MustUnWrap

func MustUnWrap(src http.ResponseWriter, target interface{})

func MustUnWrap(src interface{}, target interface{}) {

func NewErrorWrapper

func NewErrorWrapper(errHandler ErrorWriter) wrap.Wrapper

NewErrorWrapper creates a new "github.com/go-on/wrap.Wrapper for the given ErrorWriter

func NewPtr

func NewPtr(ty reflect.Type) interface{}

copied from github.com/metakeule/meta newPtr returns a reference to a new reference to a new empty value based on Type

func ReverseProxy

func ReverseProxy(rev *httputil.ReverseProxy) wrap.Wrapper

func ReverseProxyByUrl

func ReverseProxyByUrl(urlbase string) wrap.Wrapper

func UnWrap

func UnWrap(src http.ResponseWriter, target interface{}) error

consider a struct that is a http.ResponseWriter via embedding now we want to unwrap this struct to get its properties. since the struct we are looking for might not be the src but instead itself wrapped inside the ResponseWriter property of the given src we will do it recursivly untill be get the struct we look for or did not find it

func WriteContentRange

func WriteContentRange(w http.ResponseWriter, start, end, total int)

Types

type Context

if it returns nil, no further processing is done the returned responsewriter must be a pointer to some struct that inherits from http.ResponseWriter if the given function wraps the given ResponseWriter, it must set the inner ResponseWriter by itself

func (Context) Wrap

func (c Context) Wrap(in http.Handler) (out http.Handler)

type ErrorWriter

type ErrorWriter interface {

	// WriteError is like a http.Handler but gets as additional argument the error that happened
	WriteError(http.ResponseWriter, *http.Request, error)
}

ErrorWriter has a method WriteError to write error information to ResponseWriters

type Generater

type Generater interface {
	New(w http.ResponseWriter, r *http.Request) http.ResponseWriter
}

type GeneraterFunc

type GeneraterFunc func(w http.ResponseWriter, r *http.Request) http.ResponseWriter

func (GeneraterFunc) New

type HTTPStatusError

type HTTPStatusError struct {

	// Code has the http status code that was written to the http.ResponseWriter that was written to
	// it is always >= 400
	Code int

	// Header has the Header of the http.ResponseWriter that was written to
	Header http.Header
}

HTTPStatusError is an error that is based on what was written to a http.ResponseWriter any status code >= 400 is considered an error

func (HTTPStatusError) Error

func (h HTTPStatusError) Error() string

Error fulfills the error interface

type RangeRequest

type RangeRequest struct {
	AcceptRanges []string
	Max          int    // max number of results
	SortBy       string // key for sorting
	Desc         bool   // if false, the sort order is ascending (default), otherwise descending
	Start        int
	End          int
}

func ParseRangeRequest

func ParseRangeRequest(rq *http.Request, acceptedKeys ...string) (*RangeRequest, error)

type Validatable

type Validatable interface {

	// Validate does a validation and returns nil, if the validation was successful, otherwise
	// a ValidationError
	Validate() ValidationError
}

Validatable has a Validate method that returns a ValidationError error in case of an error, or nil otherwise.

type ValidationError

type ValidationError interface {
	Error() string

	// ValidationErrors returns a map that associates value names to
	// the corresponding error slices. The empty string
	// is used to refer to the complete value set as an entity.
	ValidationErrors() map[string][]error
}

ValidationError is an interface for validation errors. Since validation often happens on a set of values, it is not possible to express which value has which error with the standard error interface. Therefor ValidationError requires an additional method ValidationErrors that returns an association of value names to error slices.

Jump to

Keyboard shortcuts

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