Coder Social home page Coder Social logo

albodelu / fuel Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kittinunf/fuel

0.0 1.0 0.0 1.83 MB

The easiest HTTP networking library for Kotlin/Android

Home Page: https://fuel.gitbook.io/documentation/

License: MIT License

Shell 0.11% Kotlin 99.89%

fuel's Introduction

Fuel

Kotlin bintray Build Status Codecov

The easiest HTTP networking library for Kotlin/Android.

You are looking at the documentation for 2.x.y.. If you are looking for the documentation for 1.x.y, checkout the 1.16.0 README.md

Features

  • HTTP GET/POST/PUT/DELETE/HEAD/PATCH requests in a fluent style interface
  • Asynchronous and blocking requests
  • Download as a file
  • Upload files, Blobs, DataParts as multipart/form-data
  • Cancel asynchronous request
  • Debug logging / convert to cUrl call
  • Deserialization into POJO / POKO
  • Requests as coroutines
  • API Routing

Installation

You can download and install Fuel with Maven and Gradle. The core package has the following dependencies:

  • Kotlin - 1.3.0
  • Coroutine - 1.0.0
compile 'com.github.kittinunf.fuel:<package>:<latest-version>'

Each of the extensions / integrations has to be installed separately.

Package Description
fuel Core package
fuel-coroutines KotlinX: Execution with coroutines
fuel-android Android: Automatically invoke handler on Main Thread when using Android Module
fuel-livedata Android Architectures: Responses as LiveData
fuel-rxjava Reactive Programming: Responses as Single (RxJava 2.x)
fuel-reactor Reactive Programming: Responses as Mono (Project Reactor 3.x)
fuel-gson (De)serialization: Gson
fuel-kotlinx-serialization (De)serialization: KotlinX Serialization
fuel-json Deserialization: Json
fuel-forge Deserialization: Forge
fuel-jackson Deserialization: Jackson
fuel-moshi Deserialization: Moshi

Quick start

Fuel requests can be made on the Fuel namespace object, any FuelManager or using one of the String extension methods. If you specify a callback the call is async, if you don't it's blocking.

"https://httpbin.org/get"
  .httpGet()
  .responseString { request, response, result ->
    when (result) {
      is Result.Failure -> {
        val ex = result.getException()
      }
      is Result.Success -> {
        val data = result.get()
      }
    }
  }

// You can also use Fuel.get("https://httpbin.org/get").responseString { ... }
// You can also use FuelManager.instance.get("...").responseString { ... }

Fuel and the extension methods use the FuelManager.instance under the hood. You can use this FuelManager to change the default behaviour of all requests:

FuelManager.instance.basePath = "https://httpbin.org"

"/get"
  .httpGet()
  .responseString { request, response, result -> /*...*/ }
// This is a GET request to "https://httpbin.org/get"

Detailed usage

Check 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? fuel: Basic usage is all you need.

Basic functionality

Responses

(De)serialization

Other libraries

If you like Fuel, you might also like other libraries of mine;

  • Result - The modelling for success/failure of operations in Kotlin
  • Fuse - A simple generic LRU memory/disk cache for Android written in Kotlin
  • Forge - Functional style JSON parsing written in Kotlin
  • ReactiveAndroid - Reactive events and properties with RxJava for Android SDK

Credits

Fuel is brought to you by contributors.

Licenses

Fuel is released under the MIT license.

fuel's People

Contributors

kittinunf avatar markgilchrist avatar yoavst avatar sleeplessbyte avatar inoles avatar kindraywind avatar nikkyai avatar babedev avatar spand avatar bmsantos avatar kucherenkoihor avatar parkerk avatar deiga avatar pawin avatar carmas123 avatar victoralbertos avatar ismail-s avatar guppster avatar dmitry-zhuravlev avatar sschuberth avatar worker8 avatar timbuethe avatar judrummer avatar tomaskit avatar dobashi avatar follower avatar huiyiqun avatar krimpedance avatar mbreithu avatar renanlukas avatar

Watchers

Al B. avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.