A "fluent" OkHTTP library for Kotlin based on string extensions.

Related tags

Networking okfluent
Overview

okfluent

A "fluent" OkHTTP library for Kotlin based on string extensions. Do not take this project seriously, I just wanted to show that this kind of thing could be done.

The concept was originally derived from Flurl, a C# library that achieves a similar purpose.

Getting the dependency

Maven

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>
<dependency>
    <groupId>com.github.wale</groupId>
    <artifactId>okfluent</artifactId>
    <version>0.1.0</version>
</dependency>

Gradle

(Groovy DSL)

repositories {
    maven { url "https://jitpack.io" }
}
dependencies {
    implementation "com.github.wale:okfluent:0.1.0"
}

(Kotlin DSL)

repositories {
    maven(url = "https://jitpack.io")
}

dependencies {
    implementation("com.github.wale:okfluent:0.1.0")
}

How to use

A simple request to httpbin.org:

fun main() {
    val req = "https://httpbin.org/get"
        .get()
        .header { "User-Agent" to "OkFluent/1.0" }
        .build()
    if(req.isSuccessful) {
        print(req.body!!.string())
    }
}

...and a POST request example:

fun main() {
    val req = "https://httpbin.org/get"
        .post()
        .header { "User-Agent" to "OkFluent/1.0" }
        .body("text/plain".toMediaType(), "hello")
        .build()
}

Known issues

  • Chaining multiple headers into one .header call will not work, you must use multiple .header calls for each header.

License

This is licensed under the MIT license

You might also like...
A Kotlin client for the gRPC based Bar Service
A Kotlin client for the gRPC based Bar Service

Bar Service Kotlin Client Overview This directory contains a simple bar service client written in Kotlin against generated models (protos) You can fin

Easy, asynchronous, annotation-based SOAP for Android

IceSoap IceSoap provides quick, easy, asynchronous access to SOAP web services from Android devices. It allows for SOAP responses to be bound to Java

Cli lightning network server, based on LDK (rust-lightning). Provides DUMB-RPC interface (telnet friendly).

Hello Lightning Cli lightning network server, based on LDK (rust-lightning). Provides DUMB-RPC interface (telnet friendly). Example: Build it run it:

Kotlin-echo-client - Echo client using Kotlin with Ktor networking library
Kotlin-echo-client - Echo client using Kotlin with Ktor networking library

Overview This repository contains an echo server implemented with Kotlin and kto

Repo of the Open Source Android library : RoboSpice. RoboSpice is a modular android library that makes writing asynchronous long running tasks easy. It is specialized in network requests, supports caching and offers REST requests out-of-the box using extension modules.
HttpMocker is a simple HTTP mocking library written in Kotlin to quickly and easily handle offline modes in your apps

HttpMocker HttpMocker is a very lightweight Kotlin library that allows to mock HTTP calls relying on either OkHttp or the Ktor client libraries. It ca

Kotlin HTTP requests library. Similar to Python requests.

khttp khttp is a simple library for HTTP requests in Kotlin. It functions similarly to Python's requests module. import khttp.get fun main(args: Arra

The easiest HTTP networking library for Kotlin/Android

Fuel 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

An RPC library for Kotlin services that strives to balance developer productivity and performance.

IndieRpc An RPC library for Kotlin services that strives to balance developer productivity and performance. IndieRpc is inspired by Golang's net/rpc p

Releases(0.1.2)
Owner
Duale Siad
JVM programmer, student, person. Pronounced /wɐːli:/
Duale Siad
SimpleInterceptor for okhttp

SimpleInterceptor Simpleinceptor is the interception interface tool of Android okhttp client, which is convenient for testing or development and quick

zhonghua 25 Jun 21, 2022
Customizable OkHttp Logging Interceptor

An OkHttp interceptor which logs HTTP request and response data and allows output customization.

Bartek Wesołowski 22 Aug 13, 2022
A basic list application designed using MVVM pattern with Retrofit, OkHttp, and Hilt for dependency injection

FRExercise A basic list application designed using MVVM pattern with Retrofit, O

null 0 Dec 22, 2021
A Beautiful Log Printer For OkHttp.

LogDog A Beautiful Log Printer For OkHttp. It looks like this: Import repositories { maven { url 'https://jitpack.io' } } //something else... impl

Michael Lee 3 Jun 21, 2022
NiceHttp - A small and simple OkHttp wrapper to ease scraping

NiceHttp - A small and simple OkHttp wrapper to ease scraping

LagradOst 19 Dec 17, 2022
A simple okhttp interceptor to mock api's

mockp-interceptor Mockp-interceptor is a library to simplify Android development requests that uses Retrofit and OkHttp. This library will mock reques

Bruno Gabriel dos Santos 17 Oct 31, 2022
Asynchronous socket, http(s) (client+server) and websocket library for android. Based on nio, not threads.

AndroidAsync AndroidAsync is a low level network protocol library. If you are looking for an easy to use, higher level, Android aware, http request li

Koushik Dutta 7.3k Jan 2, 2023
Android network client based on Cronet. This library let you easily use QUIC protocol in your Android projects

Android network client based on Cronet. This library let you easily use QUIC protocol in your Android projects

VK.com 104 Dec 12, 2022
Multiplatform coroutine-based HTTP client wrapper for Kotlin

networkinkt This is a lightweight HTTP client for Kotlin. It relies on coroutines on both JS & JVM platforms. Here is a simple GET request: val text =

Egor Zhdan 31 Jul 27, 2022
A gRPC Kotlin based server and client starter that builds with Gradle and runs on the JVM

gRPC Kotlin starter Overview This directory contains a simple bar service written as a Kotlin gRPC example. You can find detailed instructions for bui

Hypto 8 Sep 19, 2022