Skip to content

rybalkinsd/kohttp

Repository files navigation

Introduction

Build Status Maven Central codecov Codacy Badge Kotlin Awesome Kotlin Badge Join the chat at https://gitter.im/kohttp/communitystar this repo

Kotlin DSL http client

Features

๐Ÿ”น Developers Experinece-driven library without verbosity.

๐Ÿ”น Providing a native way to use http client in Kotlin.

๐Ÿ”น HTTP GET/POST/PUT/HEAD/DELETE/PATCH requests.

๐Ÿ”น Asynchronous and blocking requests.

๐Ÿ”น Upload files.

๐Ÿ”น Logging - easily dump your http requests or convert them to cURL commands.

๐Ÿ”น Minimal footprint.

Quick start

val response = "https://my-host.com/users?admin=true".httpGet()
// use integration with your favorite serialization library
val usersData = users.toJson()

val pushNotifications: List<Deferred<Response>> = usersData.map {
    httpPostAsync {
        url("https://my-host.com/friends/push")
        
        param {
            "userId" to it[id]
            "eventType" to NewFriend
        }
        
        header {
            "locale" to "en_EN"
            cookie {
                "user_session" to "toFycNV"
                "authToken" to "d2dwa6011w96c93ct3e3493d4a1b5c8751563217409"
            }
        }
    }
}

About kohttp

Installation

Gradle

Kotlin DSL:

implementation(group = "io.github.rybalkinsd", name = "kohttp", version = "0.11.1")

Groovy DSL:

implementation 'io.github.rybalkinsd:kohttp:0.11.1'

Maven:

<dependency>
  <groupId>io.github.rybalkinsd</groupId>
  <artifactId>kohttp</artifactId>
  <version>0.11.1</version>
</dependency>

Table of contents