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.

24 lines
411 B

2 years ago
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)
}
}
}