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

Handle successful responses with empty body #14

Merged
merged 1 commit into from May 12, 2020
Merged

Conversation

haroldadmin
Copy link
Owner

These changes cater to the feature request added in issue #9.

  • Ability to handle empty response bodies
    The current version of the call adapter defaults to returning NetworkResponse.ServerError when the response body is empty. Now this case can handled by expressing the success response type as Unit.
@GET("/empty-body-endpoint")
suspend fun getEmptyBodyResponse(): NetworkResponse<Unit, ErrorType>
  • Centralize logic to convert a retrofit Response to a NetworkResponse in a ResponseHandler class.

These changes cater to the feature request added
in issue #9.
Copy link

@lukaszkalnik lukaszkalnik left a comment

Choose a reason for hiding this comment

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

The special case for Unit looks good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants