kohttp
Search…
Introduction
Kotlin DSL http client

Features

🔹 Developers Experience-driven library without verbosity.
🔹 Native way to use http client in Kotlin.
🔹 HTTP GET/POST/PUT/HEAD/DELETE/PATCH requests.
🔹 Asynchronous and blocking requests.
🔹 Logging - easily dump your http requests or convert them to cURL commands.
🔹 Minimal footprint.

Quick start

1
// Use String or URL extensions send simple request
2
val response = "https://my-host.com/users?admin=true".httpGet()
3
4
// Parse response with your favorite library
5
val users = response.toJson()
6
7
// Use sync or async methods to send your requests
8
// Configure method params, headers, cookies and body in a concise way
9
val notifications: List<Deferred<Response>> = users.forEach { user ->
10
httpPostAsync {
11
url("https://my-host.com/friends/push")
12
13
param {
14
"userId" to user[id]
15
"eventType" to NewFriend
16
}
17
18
header {
19
"locale" to "en_EN"
20
cookie {
21
"user_session" to "toFycNV"
22
"authToken" to "d2dwa6011w96c93ct3e3493d4a1b5c8751563217409"
23
}
24
}
25
}
26
}
Copied!

Samples

About kohttp

Installation

Gradle

Kotlin DSL:
1
implementation(group = "io.github.rybalkinsd", name = "kohttp", version = "0.12.0")
Copied!
Groovy DSL:
1
implementation 'io.github.rybalkinsd:kohttp:0.12.0'
Copied!

Maven:

1
<dependency>
2
<groupId>io.github.rybalkinsd</groupId>
3
<artifactId>kohttp</artifactId>
4
<version>0.12.0</version>
5
</dependency>
Copied!

Table of contents

Last modified 1yr ago