Skip to content

Commit

Permalink
GH-85: pass provider deps to decoder wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
skipor committed Feb 18, 2018
1 parent 536169c commit 60b4df3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions core/provider/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ func NewJSONProvider(newAmmo func() core.Ammo, conf JSONProviderConfig) core.Pro
// decode data into intermediate struct, but then transform in into desired ammo.
// For example, decode {"body":"some data"} into struct { Data string }, and transform it to
// http.Request.
func NewCustomJSONProvider(wrapDecoder func(decoder AmmoDecoder) AmmoDecoder, newAmmo func() core.Ammo, conf JSONProviderConfig) core.Provider {
func NewCustomJSONProvider(wrapDecoder func(deps core.ProviderDeps, decoder AmmoDecoder) AmmoDecoder, newAmmo func() core.Ammo, conf JSONProviderConfig) core.Provider {
var newDecoder NewAmmoDecoder = func(deps core.ProviderDeps, source io.Reader) (AmmoDecoder, error) {
decoder := NewJSONAmmoDecoder(source, conf.Buffer.BufferSizeOrDefault())
if wrapDecoder != nil {
decoder = wrapDecoder(decoder)
decoder = wrapDecoder(deps, decoder)
}
return decoder, nil
}
Expand Down
2 changes: 1 addition & 1 deletion core/provider/json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func TestCustomJSONProvider(t *testing.T) {
newAmmo := func() core.Ammo {
return &testJSONAmmo{}
}
wrapDecoder := func(decoder AmmoDecoder) AmmoDecoder {
wrapDecoder := func(_ core.ProviderDeps, decoder AmmoDecoder) AmmoDecoder {
return AmmoDecoderFunc(func(ammo core.Ammo) error {
err := decoder.Decode(ammo)
if err != nil {
Expand Down

0 comments on commit 60b4df3

Please sign in to comment.