Either Call Adapter Factory
A CallAdapter.Factory which supports suspend + Either as the return type
Adding this to Retrofit will enable you to return Either from your service methods.
import arrow.core.Either
import retrofit2.http.GET
data class User(val name: String)
data class ErrorBody(val msg: String)
interface MyService {
@GET("/user/me")
suspend fun user(): Either<ErrorBody, User>
@GET("/user/me")
suspend fun userResponse(): Either<ErrorBody, User>
}Content copied to clipboard
Using Either as the return type means that 200 status code and HTTP errors return a value, other exceptions will throw.
ResponseE is similar to retrofit2.Response but uses Either for the response body.
Constructors
Types
Functions
Link copied to clipboard
open operator override fun get(returnType: Type, annotations: Array<Annotation>, retrofit: Retrofit): CallAdapter<*, *>?
Content copied to clipboard