-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- make factory.Get method accepts options to provide default err decoder without declaration - refactored defaul error decoder to provide more detailed information on error responses from clients
- Loading branch information
Showing
3 changed files
with
106 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package client | ||
|
||
type options struct { | ||
errDecoder ErrDecoder | ||
driverWrappers []DriverWrapper | ||
} | ||
|
||
type Option interface { | ||
Apply(*options) | ||
} | ||
|
||
type withOption func(*options) | ||
|
||
func (wf withOption) Apply(opts *options) { | ||
wf(opts) | ||
} | ||
|
||
func WithErrDecoder(ed ErrDecoder) Option { | ||
return withOption(func(o *options) { | ||
o.errDecoder = ed | ||
}) | ||
} | ||
|
||
func WithDriverWrappers(wrappers ...DriverWrapper) Option { | ||
return withOption(func(o *options) { | ||
o.driverWrappers = append(o.driverWrappers, wrappers...) | ||
}) | ||
} |