You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
340 B

2 years ago
package middleware
import (
"context"
)
func Validate() Middleware {
return func(handler Handler) Handler {
return func(ctx context.Context, a any) (any, error) {
if r, ok := a.(interface {
Validate() error
}); ok {
if err := r.Validate(); err != nil {
return nil, err
}
}
return handler(ctx, a)
}
}
}