Skip to content

Commit

Permalink
Merge pull request #168 from zhangyangjing/patch-1
Browse files Browse the repository at this point in the history
Allow custom response handlers to return nil result values
  • Loading branch information
baywet committed May 9, 2024
2 parents 58dfe5c + 7578f1a commit afc0304
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Support retry after as a date.

## [1.3.4] - 2024-05-09

### Changed

- Allow custom response handlers to return nil result values.

## [1.3.3] - 2024-03-19

- Fix bug where overriding http.DefaultTransport with an implementation other than http.Transport would result in an interface conversion panic
Expand Down
18 changes: 18 additions & 0 deletions nethttp_request_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,9 @@ func (a *NetHttpRequestAdapter) Send(ctx context.Context, requestInfo *abs.Reque
span.RecordError(err)
return nil, err
}
if result == nil {
return nil, nil
}
return result.(absser.Parsable), nil
} else if response != nil {
defer a.purge(response)
Expand Down Expand Up @@ -394,6 +397,9 @@ func (a *NetHttpRequestAdapter) SendEnum(ctx context.Context, requestInfo *abs.R
span.RecordError(err)
return nil, err
}
if result == nil {
return nil, nil
}
return result.(absser.Parsable), nil
} else if response != nil {
defer a.purge(response)
Expand Down Expand Up @@ -445,6 +451,9 @@ func (a *NetHttpRequestAdapter) SendCollection(ctx context.Context, requestInfo
span.RecordError(err)
return nil, err
}
if result == nil {
return nil, nil
}
return result.([]absser.Parsable), nil
} else if response != nil {
defer a.purge(response)
Expand Down Expand Up @@ -496,6 +505,9 @@ func (a *NetHttpRequestAdapter) SendEnumCollection(ctx context.Context, requestI
span.RecordError(err)
return nil, err
}
if result == nil {
return nil, nil
}
return result.([]any), nil
} else if response != nil {
defer a.purge(response)
Expand Down Expand Up @@ -555,6 +567,9 @@ func (a *NetHttpRequestAdapter) SendPrimitive(ctx context.Context, requestInfo *
span.RecordError(err)
return nil, err
}
if result == nil {
return nil, nil
}
return result.(absser.Parsable), nil
} else if response != nil {
defer a.purge(response)
Expand Down Expand Up @@ -636,6 +651,9 @@ func (a *NetHttpRequestAdapter) SendPrimitiveCollection(ctx context.Context, req
span.RecordError(err)
return nil, err
}
if result == nil {
return nil, nil
}
return result.([]any), nil
} else if response != nil {
defer a.purge(response)
Expand Down
2 changes: 1 addition & 1 deletion user_agent_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func NewUserAgentHandlerOptions() *UserAgentHandlerOptions {
return &UserAgentHandlerOptions{
Enabled: true,
ProductName: "kiota-go",
ProductVersion: "1.3.3",
ProductVersion: "1.3.4",
}
}

Expand Down

0 comments on commit afc0304

Please sign in to comment.