Skip to content

Commit

Permalink
Add client interceptors
Browse files Browse the repository at this point in the history
  • Loading branch information
bufdev committed Sep 18, 2020
1 parent 9a12f11 commit 2688b1f
Show file tree
Hide file tree
Showing 21 changed files with 1,463 additions and 316 deletions.
12 changes: 10 additions & 2 deletions client_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ type ClientOption func(*ClientOptions)

// ClientOptions encapsulate the configurable parameters on a Twirp client.
type ClientOptions struct {
Hooks *ClientHooks
pathPrefix *string
Interceptors []Interceptor
Hooks *ClientHooks
pathPrefix *string
}

func (opts *ClientOptions) PathPrefix() string {
Expand All @@ -33,6 +34,13 @@ func (opts *ClientOptions) PathPrefix() string {
return *opts.pathPrefix
}

// WithClientInterceptors defines the interceptors for a Twirp client.
func WithClientInterceptors(interceptors ...Interceptor) ClientOption {
return func(o *ClientOptions) {
o.Interceptors = append(o.Interceptors, interceptors...)
}
}

// WithClientHooks defines the hooks for a Twirp client.
func WithClientHooks(hooks *ClientHooks) ClientOption {
return func(o *ClientOptions) {
Expand Down
148 changes: 128 additions & 20 deletions clientcompat/internal/clientcompat/clientcompat.twirp.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2688b1f

Please sign in to comment.