Skip to content

Commit

Permalink
Enhancement: Introduce Option Interface for Future Interceptor Custom…
Browse files Browse the repository at this point in the history
…ization (#615)

* checkpoint

* checkpoint
  • Loading branch information
elliotmjackson authored Aug 16, 2023
1 parent eef4b06 commit c93f93f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions interceptors/protovalidate/protovalidate.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@ import (
"google.golang.org/protobuf/proto"
)

// Option interface is currently empty and serves as a placeholder for potential future implementations.
// It allows adding new options without breaking existing code.
type Option interface {
unimplemented()
}

// UnaryServerInterceptor returns a new unary server interceptor that validates incoming messages.
func UnaryServerInterceptor(validator *protovalidate.Validator) grpc.UnaryServerInterceptor {
func UnaryServerInterceptor(validator *protovalidate.Validator, opts ...Option) grpc.UnaryServerInterceptor {
return func(
ctx context.Context,
req interface{},
Expand All @@ -36,7 +42,7 @@ func UnaryServerInterceptor(validator *protovalidate.Validator) grpc.UnaryServer
}

// StreamServerInterceptor returns a new streaming server interceptor that validates incoming messages.
func StreamServerInterceptor(validator *protovalidate.Validator) grpc.StreamServerInterceptor {
func StreamServerInterceptor(validator *protovalidate.Validator, opts ...Option) grpc.StreamServerInterceptor {
return func(
srv interface{},
stream grpc.ServerStream,
Expand Down

0 comments on commit c93f93f

Please sign in to comment.