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.
 
 

23 lines
411 B

package middleware
import (
"context"
"fmt"
)
func Validate() Middleware {
return func(handler Handler) Handler {
return func(ctx context.Context, a any) (any, error) {
fmt.Println("validate")
fmt.Println(ctx.Value("user-id"))
if r, ok := a.(interface {
Validate() error
}); ok {
if err := r.Validate(); err != nil {
return nil, err
}
}
return handler(ctx, a)
}
}
}