Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Intercepter ¶ added in v0.19.4
func Intercepter(ch chan extensions.BrokerMessage) extensions.Middleware
Intercepter is a middleware that intercepts messages in reception and in publication.
func Logging ¶
func Logging(logger extensions.Logger) extensions.Middleware
Logging is a middleware that logs messages in reception and in publication.
func Recovery ¶
func Recovery(logger extensions.Logger) extensions.Middleware
Recovery is a middleware that recovers from panic in middlewares coming after it and user code from subscription.
func Validation ¶ added in v0.52.0
func Validation(validate *validator.Validate, newPayload func() any) extensions.Middleware
Validation returns a middleware that validates the message payload against the `validate:"..."` struct tags that asyncapi-codegen generates on payload types (using github.com/go-playground/validator).
newPayload must return a pointer to a fresh payload value to decode the message into, for example:
middlewares.Validation(validator.New(), func() any { return &UserMessagePayload{} })
The middleware unmarshals msg.Payload (JSON) into that value and validates it. If the payload cannot be unmarshaled or fails validation, it returns an error, which aborts processing of the message — so invalid messages never reach user code (on reception) and are not sent (on publication).
A fresh value is created for every message, so the middleware is safe for concurrent use.
Types ¶
This section is empty.