Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrorPipesNil = fmt.Errorf("handler.New: pipesGroup nil") ErrorTNil = fmt.Errorf("handler.New: t nil") ErrorConverterNil = fmt.Errorf("handler.New: converter nil") ErrorPointerNonStructType = fmt.Errorf("handler.New: pointer to non-struct type as constructor") ErrorNotInterfacebleValue = fmt.Errorf("handler.New: not interfaceble value") ErrorInvalidConstructorType = fmt.Errorf("handler.New: invalid constructor type") ErrorTCtorFuncHaveArguments = fmt.Errorf("handler.New: t ctor func have arguments") ErrorTCtorFuncMoreThanOneReturnType = fmt.Errorf("handler.New: t ctor func have more than one return type") ErrorTCtorFuncVoid = fmt.Errorf("handler.New: t ctor func doesn't return any types") )
View Source
var AbortPipeGroup *reflect.Value = nil
If pipe returns this value, next pipe in group will not call
Functions ¶
func ContinuePipeGroup ¶
If pipe returns action reflect value as nil it means that next pipe should not be called
If returns pointer to reflect value, next pipe should be called
Types ¶
type Converter ¶
type Converter func(GenericHandlerFunc) interface{}
Converter converts generic handler to specified. It's a function what accepts generic handler and returns new function what converts to desired function what accepts your library or framework
Example:
var EchoHandler handler.Converter = func(f handler.GenericHandlerFunc) interface{} { return echo.HandlerFunc( func(ctx echo.Context) error { return f(ctx) }, ) }
type GenericHandlerFunc ¶
type GenericHandlerFunc func(...interface{}) error
Generic handler represents generic handler func
type Pipe ¶
Pipe represents a execution pipe in handler
Example:
var BindRequest Pipe = func(instance reflect.Value, args ...interface{}) (reflect.Value, error) { context := args[0].(echo.Context) if modelValue := instance.FieldByName("Model"); modelValue.IsValid() { model := modelValue.Addr().Interface() if err := context.Bind(&model); err != nil { return nil, context.JSON(http.StatusBadRequest, err) } } return instance, nil }
Source Files
¶
Click to show internal directories.
Click to hide internal directories.