fuel
fuel copied to clipboard
[3.x] Feedback
I am asking for any kind of feedback on the next version of Fuel that is based on OkHttp with a support of ktor. It is not backward compatibility. It requires Java 8+. If you want to use it on Android, it have to be Android 5+.
So far, there is one known issue on ktor is unsupported websockets.
If you really want to test it,
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.kittinunf.fuel:fuel:3.x-SNAPSHOT'
}
I would like to test this with our KTOR application. Easier said than done because everything has changed and the changes are really major and only very thing documentation exists.
Due to this being such a major refactoring I at least would like to see some kind of migration guide. Or just a little bit more documentation how does the new API work.
I have so many questions by just trying to set up the environment to our old project.
fuel-coroutine package is gone? Is it now in the core? fuel-jackson package is gone? is it now in the core? or part of OKHTTP?
How to replace FuelManager?
How to handle async request with the new API?
How to create an instance from Fuel with custom OKHttp configuration?
Here's few things that popped in to my mind by just trying replace the 2.x with 3.x.
It is really coroutine-based HTTP Client with fully async. I can add jackson back.
val client = OkHttpClient.Builder()
.addNetworkInterceptor {
val originalResponse = it.proceed(it.request())
originalResponse.newBuilder()
.body(ProgressResponseBody(originalResponse.body!!, progressListener))
.build()
}.build()
val httpLoader = HttpLoader.Builder().okHttpClient(client).build()
If you want to add custom OkHttp configuration for it
on Android, you can use the HttpLoaderFactory on the Application class to simplified the singleton.
Jackson is now added to the 3.x branch.
Let's move our development effort to 3.x!
How long until 3.x is released? I could hardly wait~~~
I tried the latest snapshot because it doesn't suffer from #827. Here's some feedback:
It works fine, but seems surprisingly bare-bones compared to the previous version. I'm missing things like:
- a nice way to handle url parameters
- adding headers one by one
- jackson extension for body
- a fluent way to build and send a complex request
I tried the latest snapshot because it doesn't suffer from #827. Here's some feedback:
It works fine, but seems surprisingly bare-bones compared to the previous version. I'm missing things like:
- a nice way to handle url parameters
- adding headers one by one
- jackson extension for body
- a fluent way to build and send a complex request
-
I may be thinking about it. You could write issues about it. sounds like Extensions per platform. like Java, HttpURL from OkHttp.
-
Headers already Map.
-
Sorry, I can't do this over multiplatform
-
what kind of complex requests you are looking for?
- What's the issue with how 2.x did it?
Fuel.get("http://base.url/path", "param1" to "value1", "param2" to "value2")
I like to write things like
fun Request.Builder.addSomeBasicHeaders() = apply {
// add headers every request needs
}
request.addSomeBasicHeaders().addHeader("specificHeader", "value")
But the request builder in 3.0 doesn't allow for this pattern.
Something like
fun Request.Builder.objectBody(body: Any) = body(objectMapper.writeValueAsString(body))
should work
In 2.x you could write something like
Fuel.post(...)
.header(...)
.header(...)
.body(...)
.responseObject<...>()
This is the pattern I'm missing in 3.0
With https://github.com/kittinunf/fuel/blob/main/fuel/src/commonMain/kotlin/fuel/Fuels.kt and https://github.com/kittinunf/fuel/blob/main/fuel/src/commonMain/kotlin/fuel/Strings.kt
you can do
Fuel.post("url", "Hello there", mapOf("")).body
or
"url".httpPost("Hello There", mapOf("")).body
you replace response body (String) with another library like toJson()
@F43nd1r
About parameters, Do you use other types other than String?
I think it's convenient to be able to pass in booleans and numbers, but I guess not really necessary
I think it's convenient to be able to pass in booleans and numbers, but I guess not really necessary
oh thanks, I already make a PR about it with parameters.