Documentation ¶
Index ¶
- Constants
- type CallHandlerError
- type HandlerError
- type HandlerParameter
- type HandlerVersion
- type HandlersManager
- func (hm *HandlersManager) CallHandler(ctx context.Context, handler HandlerVersion, params reflect.Value) (interface{}, *CallHandlerError)
- func (hm *HandlersManager) FindHandler(path string, version int) HandlerVersion
- func (hm *HandlersManager) FindHandlerByRoute(route string) HandlerVersion
- func (hm *HandlersManager) GetHandlerInfo(path string) *handlerInfo
- func (hm *HandlersManager) GetHandlersPaths() []string
- func (hm *HandlersManager) MustRegisterHandler(h IHandler)
- func (hm *HandlersManager) MustRegisterHandlers(handlers ...IHandler)
- func (hm *HandlersManager) Pkg() string
- func (hm *HandlersManager) RegisterHandler(h IHandler) error
- func (hm *HandlersManager) RegisterHandlers(handlers ...IHandler) error
- func (*HandlersManager) UnmarshalParameters(ctx context.Context, handler HandlerVersion, ...) (reflect.Value, error)
- type HandlersManagerCallbacks
- type IHandler
- type IHandlerParameters
Constants ¶
View Source
const ( ErrorInParameters = iota ErrorReturnedFromCall ErrorInvalidMethod ErrorWriteResponse ErrorUnknown ErrorPanic )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CallHandlerError ¶
func (*CallHandlerError) Error ¶
func (e *CallHandlerError) Error() string
func (*CallHandlerError) ErrorCode ¶
func (e *CallHandlerError) ErrorCode() string
func (*CallHandlerError) UserMessage ¶
func (e *CallHandlerError) UserMessage() string
type HandlerError ¶
func (*HandlerError) Error ¶
func (e *HandlerError) Error() string
type HandlerParameter ¶
type HandlerParameter struct { Name string Description string Key string Path []string RawType reflect.Type IsRequired bool Fields []HandlerParameter // contains filtered or unexported fields }
func (*HandlerParameter) GetKey ¶
func (p *HandlerParameter) GetKey() string
type HandlerVersion ¶
type HandlerVersion *handlerVersion
type HandlersManager ¶
type HandlersManager struct {
// contains filtered or unexported fields
}
func NewHandlersManager ¶
func NewHandlersManager(handlersPath string, callbacks HandlersManagerCallbacks) *HandlersManager
func (*HandlersManager) CallHandler ¶
func (hm *HandlersManager) CallHandler(ctx context.Context, handler HandlerVersion, params reflect.Value) (interface{}, *CallHandlerError)
func (*HandlersManager) FindHandler ¶
func (hm *HandlersManager) FindHandler(path string, version int) HandlerVersion
FindHandler returns a handler by given non-versioned path and given version number
func (*HandlersManager) FindHandlerByRoute ¶
func (hm *HandlersManager) FindHandlerByRoute(route string) HandlerVersion
FindHandlerByRoute returns a handler by fully qualified route to that particular version of the handler
func (*HandlersManager) GetHandlerInfo ¶
func (hm *HandlersManager) GetHandlerInfo(path string) *handlerInfo
func (*HandlersManager) GetHandlersPaths ¶
func (hm *HandlersManager) GetHandlersPaths() []string
func (*HandlersManager) MustRegisterHandler ¶
func (hm *HandlersManager) MustRegisterHandler(h IHandler)
func (*HandlersManager) MustRegisterHandlers ¶
func (hm *HandlersManager) MustRegisterHandlers(handlers ...IHandler)
func (*HandlersManager) Pkg ¶
func (hm *HandlersManager) Pkg() string
func (*HandlersManager) RegisterHandler ¶
func (hm *HandlersManager) RegisterHandler(h IHandler) error
func (*HandlersManager) RegisterHandlers ¶
func (hm *HandlersManager) RegisterHandlers(handlers ...IHandler) error
func (*HandlersManager) UnmarshalParameters ¶
func (*HandlersManager) UnmarshalParameters(ctx context.Context, handler HandlerVersion, handlerParameters IHandlerParameters) (reflect.Value, error)
type HandlersManagerCallbacks ¶
type HandlersManagerCallbacks struct { // OnHandlerRegistration will be called only one time for each handler version while handler registration is in progress OnHandlerRegistration func(path string, method reflect.Method) (extraData interface{}) // OnError will be called if any error occurs while CallHandler() method is in processing OnError func(ctx context.Context, err error) // OnSuccess will be called if CallHandler() method is successfully finished OnSuccess func(ctx context.Context, result interface{}) // AppendInParams will be called for each handler call and can append extra parameters to params AppendInParams func(ctx context.Context, preparedParams []reflect.Value, extraData interface{}) (context.Context, []reflect.Value, error) }
type IHandlerParameters ¶
type IHandlerParameters interface { Fork(m map[string]interface{}) interface{} Parse() error IsExists([]string, string) bool GetString([]string, string) (string, error) GetBool([]string, string) (bool, error) GetUint([]string, string) (uint, error) GetByte([]string, string) (byte, error) GetUint8([]string, string) (uint8, error) GetUint16([]string, string) (uint16, error) GetUint32([]string, string) (uint32, error) GetUint64([]string, string) (uint64, error) GetInt([]string, string) (int, error) GetInt8([]string, string) (int8, error) GetInt16([]string, string) (int16, error) GetInt32([]string, string) (int32, error) GetInt64([]string, string) (int64, error) GetFloat32([]string, string) (float32, error) GetFloat64([]string, string) (float64, error) TraverseSlice(path []string, name string, h func(i int, v interface{}) error) (bool, error) TraverseMap(path []string, name string, h func(k string, v interface{}) error) (bool, error) }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.