Skip to content

Commit

Permalink
Merge pull request #276 from bufbuild/interceptors
Browse files Browse the repository at this point in the history
Add interceptors
  • Loading branch information
marioizquierdo authored Sep 25, 2020
2 parents 282c5d0 + ae97c56 commit 403a70c
Show file tree
Hide file tree
Showing 29 changed files with 2,750 additions and 274 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ test_python_client: generate build/clientcompat build/pycompat

setup:
./install_proto.bash
GOPATH=$(CURDIR)/_tools go install github.com/twitchtv/retool/...
GO111MODULE=off GOPATH=$(CURDIR)/_tools GOBIN=$(CURDIR)/_tools/bin go get github.com/twitchtv/retool
$(RETOOL) build

release_gen:
Expand Down
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
234 changes: 218 additions & 16 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 403a70c

Please sign in to comment.