https://kotlinlang.org logo
#ktor
Title
# ktor
a

alexfacciorusso

02/20/2019, 11:17 AM
Hi guys! I'm trying to create a Feature that will wrap the end result of the various parsing engines (JsonFeature etc...) to a custom Response class. What's the best way of doing it? e.g. I want to be able to do
httpClient.get<Result<MyApiResponseType>>(...)
and getting a result object that will contain its success/fail state, the exception etc.
b

bdawg.io

02/20/2019, 3:59 PM
(De)serialization is already a feature of ktor. Is there any reason why you're going to reinvent the wheel?
a

alexfacciorusso

02/21/2019, 5:17 PM
I don't need something for de-serialising data; what I do need is wrapping what I receive in a
Result
object. Result is a Sealed class that will Success if the response has been successful and Failure, containing the message of the failing response, in case the response code is not successful