在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):kittinunf/fuel开源软件地址(OpenSource Url):https://github.com/kittinunf/fuel开源编程语言(OpenSource Language):Kotlin 99.9%开源软件介绍(OpenSource Introduction):FuelThe easiest HTTP networking library for Kotlin/Android.
Features
InstallationWe offer maven and jitpack installations. Maven via bintray only has stable releases but jitpack can be used to build any branch, commit and version. MavenYou can download and install
//core
implementation 'com.github.kittinunf.fuel:fuel:<latest-version>'
//packages
implementation 'com.github.kittinunf.fuel:<package>:<latest-version>' Make sure to include repositories {
mavenCentral()
} Each of the extensions / integrations has to be installed separately.
JitpackIf you want a SNAPSHOT distribution, you can use repositories {
maven(url = "https://www.jitpack.io") {
name = "jitpack"
}
}
dependencies {
//core
implementation(group = "com.github.kittinunf.fuel", name = "fuel", version = "-SNAPSHOT")
//packages
// replace <package> with the package name e.g. fuel-coroutines
implementation(group = "com.github.kittinunf.fuel", name = "<package>", version = "-SNAPSHOT")
} or dependencies {
//core and/or packages
// replace <package> with the package name e.g. fuel-coroutines
listof("fuel", "<package>").forEach {
implementation(group = "com.github.kittinunf.fuel", name = it, version = "-SNAPSHOT")
}
} Configuration
We recommend not using Build time-outHave patience when updating the version of fuel or building for the first time as jitpack will build it, and this may cause the request to jitpack to time out. Wait a few minutes and try again (or check the status on jitpack). NOTE: do not forget to add the ForksJitpack.io also allows to build from
Quick startFuel requests can be made on the Async Usage Exampleimport com.github.kittinunf.fuel.httpGet
import com.github.kittinunf.result.Result
fun main(args: Array<String>) {
val httpAsync = "https://httpbin.org/get"
.httpGet()
.responseString { request, response, result ->
when (result) {
is Result.Failure -> {
val ex = result.getException()
println(ex)
}
is Result.Success -> {
val data = result.get()
println(data)
}
}
}
httpAsync.join()
} Blocking Usage Exampleimport com.github.kittinunf.fuel.httpGet
import com.github.kittinunf.result.Result;
fun main(args: Array<String>) {
val (request, response, result) = "https://httpbin.org/get"
.httpGet()
.responseString()
when (result) {
is Result.Failure -> {
val ex = result.getException()
println(ex)
}
is Result.Success -> {
val data = result.get()
println(data)
}
}
}
// You can also use Fuel.get("https://httpbin.org/get").responseString { ... }
// You can also use FuelManager.instance.get("...").responseString { ... }
FuelManager.instance.basePath = "https://httpbin.org"
"/get"
.httpGet()
.responseString { request, response, result -> /*...*/ }
// This is a GET request to "https://httpbin.org/get" Detailed usageCheck each of the packages documentations or the Wiki for more features, usages and examples. Are you looking for basic usage on how to set headers, authentication, request bodies and more? Basic functionalityResponses
(De)serialization
UtilityOther librariesIf you like Fuel, you might also like other libraries of mine;
CreditsFuel is brought to you by contributors. LicensesFuel is released under the MIT license. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论