Skip to content

Commit

Permalink
checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
elliotmjackson committed Aug 24, 2023
1 parent 15e6bc9 commit 97d47f2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type Option interface {
unimplemented()
}

// Interceptor implements connect.Interceptor.
// Interceptor implements the connect.Interceptor interface.
type Interceptor struct {
validator *protovalidate.Validator
}
Expand All @@ -50,6 +50,7 @@ func NewInterceptor(
}

// WrapUnary returns a new connect.UnaryFunc that wraps the given connect.UnaryFunc.
// It ensures that incoming requests are validated before being processed.
func (i *Interceptor) WrapUnary(next connect.UnaryFunc) connect.UnaryFunc {
return func(ctx context.Context, req connect.AnyRequest) (connect.AnyResponse, error) {
if err := validate(i.validator, req.Any()); err != nil {
Expand All @@ -60,6 +61,7 @@ func (i *Interceptor) WrapUnary(next connect.UnaryFunc) connect.UnaryFunc {
}

// WrapStreamingClient returns a new connect.StreamingClientFunc that wraps the given connect.StreamingClientFunc.
// It ensures that messages sent by the client are validated before transmission.
func (i *Interceptor) WrapStreamingClient(next connect.StreamingClientFunc) connect.StreamingClientFunc {
return func(ctx context.Context, spec connect.Spec) connect.StreamingClientConn {
return &streamingClientInterceptor{
Expand All @@ -70,6 +72,7 @@ func (i *Interceptor) WrapStreamingClient(next connect.StreamingClientFunc) conn
}

// WrapStreamingHandler returns a new connect.StreamingHandlerFunc that wraps the given connect.StreamingHandlerFunc.
// It ensures that messages received by the handler are validated before processing.
func (i *Interceptor) WrapStreamingHandler(next connect.StreamingHandlerFunc) connect.StreamingHandlerFunc {
return func(ctx context.Context, conn connect.StreamingHandlerConn) error {
return next(ctx, &streamingHandlerInterceptor{
Expand Down

0 comments on commit 97d47f2

Please sign in to comment.