Documentation ¶
Index ¶
- Constants
- Variables
- func IgnoreCase(name string) string
- type Handler
- type HandlerFunc
- type Mux
- func (m *Mux) Get(name string) (Handler, error)
- func (m *Mux) Handle(name string, handler interface{}) error
- func (m *Mux) HandleMethodsPrefix(prefix string, receivers ...interface{}) error
- func (m *Mux) Handlers() (handlers []RouteHandler)
- func (m *Mux) Invoke(ctx context.Context, payload []byte) ([]byte, error)
- func (m *Mux) MustHandle(name string, handler interface{})
- func (m *Mux) MustHandleMethods(receivers ...interface{})
- type RouteError
- type RouteHandler
Constants ¶
const DefaultHandlerPrefix = "Invoke"
Variables ¶
var ErrNotFound = errors.New(`route not found`)
ErrNotFound is a well-known error that a route was not found. Using std errors.New here since we don't want a stack
Functions ¶
func IgnoreCase ¶
Types ¶
type HandlerFunc ¶
HandlerFunc is a function implementing Handler
type Mux ¶
type Mux struct { // If set, it will normalize route names. RouteName func(name string) string // Decorate can intercept new handlers and add decorations Decorate func(key string, handler Handler) Handler // JSON JSON jsoniter.API // defaults to jsoniter.ConfigCompatibleWithStandardLibrary // Validate sets a custom validation function to be injected into every route handler Validate func(payload interface{}) error // IgnoreDuplicates will not return errors when duplicate route handlers are added to the mux IgnoreDuplicates bool // contains filtered or unexported fields }
Mux dispatches handling of a Lambda events
func (*Mux) Handle ¶
Handle applies any decoration and adds a handler to the mux. It fails if the handler does not meet the signature requirements. It overrides previously defined routes without error if IgnoreDuplicates is set.
func (*Mux) HandleMethodsPrefix ¶
HandleMethodsPrefix add all routes from a struct to the Mux. It fails if a method does not meet the signature requirements. It overrides previously defined routes without error if IgnoreDuplicates is set
func (*Mux) Handlers ¶
func (m *Mux) Handlers() (handlers []RouteHandler)
Handlers returns all handlers added to the mux.
func (*Mux) MustHandle ¶
func (*Mux) MustHandleMethods ¶
func (m *Mux) MustHandleMethods(receivers ...interface{})
MustHandleMethods add all routes from a struct to the Mux or panics. It overrides previously defined routes without error if IgnoreDuplicates is set
type RouteError ¶
RouteError is the error implemented by errors returned from a route handler