Documentation
¶
Index ¶
- func BindJSON[P any](c *echo.Context) (*P, error)
- func Identity[I any](in *I) (*I, error)
- func IndirectJSONInput[P any, I any](t func(*P) (*I, error)) func(c *echo.Context) (*I, error)
- func Transform[I any, O any](getInput func(c *echo.Context) (*I, error), t func(*I) (*O, error)) func(c *echo.Context) (*O, error)
- func WriteJSON[T any](c *echo.Context, val *T) error
- func Zero[I any](c *echo.Context) (*I, error)
- type Invoker
- func (i *Invoker[Tx, I, O]) Go(c *echo.Context) error
- func (i *Invoker[Tx, I, O]) WithContext(ctx context.Context) *Invoker[Tx, I, O]
- func (i *Invoker[Tx, I, O]) WithContextFunc(fn func(*echo.Context) context.Context) *Invoker[Tx, I, O]
- func (i *Invoker[Tx, I, O]) WithInputMapper(fn func(*echo.Context) (*I, error)) *Invoker[Tx, I, O]
- func (i *Invoker[Tx, I, O]) WithJSONOutput(fn func(c *echo.Context, o *O) any) *Invoker[Tx, I, O]
- func (i *Invoker[Tx, I, O]) WithJSONOutputFunc(fn func(c *echo.Context, o *O) error) *Invoker[Tx, I, O]
- func (i *Invoker[Tx, I, O]) WithOutputMapper(fn func(c *echo.Context, o *O) error) *Invoker[Tx, I, O]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IndirectJSONInput ¶
IndirectJSONInput parses the request body into a *P before passing it to a user-defined transformer function that produces a *I.
func Transform ¶
func Transform[I any, O any](getInput func(c *echo.Context) (*I, error), t func(*I) (*O, error)) func(c *echo.Context) (*O, error)
Transform returns a function that reads input from an Echo context as an *I before passing it to a user-defined transformer function that produces an *O.
Types ¶
type Invoker ¶
type Invoker[Tx operator.Transaction, I any, O any] struct { // contains filtered or unexported fields }
Invoker acts as a configuration point when binding operations to Echo handlers. Use its With* functions to customise input and output behaviour, then call Go() to invoke the operation.
func Bind ¶
func Bind[Tx operator.Transaction, I any, O any]( hub *operator.Hub[Tx], op func(*operator.OpContext[Tx], *I) (*O, error), ) *Invoker[Tx, I, O]
Bind creates an Invoker binding the operation to an Echo handler. The returned Invoker can be further customised before finally calling Go().
func BindTx ¶
func BindTx[Tx operator.Transaction, I any, O any]( hub *operator.Hub[Tx], op func(*operator.OpContext[Tx], Tx, *I) (*O, error), ) *Invoker[Tx, I, O]
BindTx creates an Invoker binding the transactional operation to an Echo handler. The returned Invoker can be further customised before finally calling Go().
func (*Invoker[Tx, I, O]) Go ¶
Go invokes the bound operation in the context of the supplied Echo request. Its signature matches echo.HandlerFunc.
func (*Invoker[Tx, I, O]) WithContext ¶
WithContext sets a static context for the operation
func (*Invoker[Tx, I, O]) WithContextFunc ¶
func (i *Invoker[Tx, I, O]) WithContextFunc(fn func(*echo.Context) context.Context) *Invoker[Tx, I, O]
WithContextFunc sets fn as a context factory for the operation.
func (*Invoker[Tx, I, O]) WithInputMapper ¶
WithInputMapper registers the binding's input mapper
func (*Invoker[Tx, I, O]) WithJSONOutput ¶
WithJSONOutput sets an output mapper that writes the result of fn as JSON