Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add interceptors #276

Merged
merged 6 commits into from
Sep 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed for any development system that has GO111MODULE and GOBIN set, and has no effect on other systems for Twirp's Makefile logic.

$(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