Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultMiddleware ¶
func DefaultMiddleware() []rf.MiddlewareFunc
Types ¶
type Handler ¶
type Handler[Req any, Res comparable] struct { // contains filtered or unexported fields }
Handler is an instance of a JSON based, POST only, jsonschema validated handler. This handler type is very opinionated and uses the yael package for handling errors.
func NewHandler ¶
func NewHandler[Req any, Res comparable]( fn RPCHandlerFunc[Req, Res], schema gojsonschema.JSONLoader, ) *Handler[Req, Res]
NewHandler returns a handler instance with the provided handler function and jsonschema to validate the request with. The 'fn' argument provided must be a function with a signature like so:
func Example(ctx context.Context, req RequestType) (ResponseType, error)
Any mismatch against the above format will result in a panic
func (*Handler[Req, Res]) Error ¶
func (rpc *Handler[Req, Res]) Error() rf.ErrorHandlerFunc
func (*Handler[Req, Res]) Handle ¶
func (h *Handler[Req, Res]) Handle() rf.HandlerFunc
type RPCHandlerFunc ¶
type RPCHandlerFunc[Req any, Res comparable] func(context.Context, Req) (Res, error)
Click to show internal directories.
Click to hide internal directories.