Documentation
¶
Index ¶
- Variables
- func Defer(h http.Handler) wrap.Wrapper
- func DeferFunc(fn func(http.ResponseWriter, *http.Request)) wrap.Wrapper
- func Generator(gen Generater) wrap.Wrapper
- func GeneratorFunc(fn func(w http.ResponseWriter, r *http.Request) http.ResponseWriter) wrap.Wrapper
- func HandlerMethod(fn interface{}) http.Handler
- func Json(t interface{}) wrap.Wrapper
- func LOGGER(prefix string) wrap.Wrapper
- func Logger(l *log.Logger) wrap.Wrapper
- func MustUnWrap(src http.ResponseWriter, target interface{})
- func NewErrorWrapper(errHandler ErrorWriter) wrap.Wrapper
- func NewPtr(ty reflect.Type) interface{}
- func ReverseProxy(rev *httputil.ReverseProxy) wrap.Wrapper
- func ReverseProxyByUrl(urlbase string) wrap.Wrapper
- func UnWrap(src http.ResponseWriter, target interface{}) error
- func WriteContentRange(w http.ResponseWriter, start, end, total int)
- type Context
- type ErrorWriter
- type Generater
- type GeneraterFunc
- type HTTPStatusError
- type RangeRequest
- type Validatable
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
var HTTP1_1 = http1_1{}
var ResponseWriterHandler wrap.Wrapper = responseWriterHandle{}
Functions ¶
func GeneratorFunc ¶
func GeneratorFunc(fn func(w http.ResponseWriter, r *http.Request) http.ResponseWriter) wrap.Wrapper
func HandlerMethod ¶
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 ¶
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 ¶
type Context func(http.ResponseWriter, *http.Request) http.ResponseWriter
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
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 ¶
func (gf GeneraterFunc) New(w http.ResponseWriter, r *http.Request) http.ResponseWriter
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.