Skip to content

HTTP Framework

uni provides a cross-platform HTTP client with automatic retry, streaming support, and reactive integration.

Overview

ComponentDescription
HTTP ClientSync and async HTTP clients
Retry StrategiesAutomatic retry for transient failures

Quick Start

scala
import wvlet.uni.http.{Http, Request}

// Create a client
val client = Http.client.newSyncClient

// Make a GET request
val response = client.send(Request.get("https://api.example.com/users"))
println(response.contentAsString)

// Close the client
client.close()

Async Client with Rx

scala
import wvlet.uni.http.Http

val asyncClient = Http.client.newAsyncClient

asyncClient
  .send(Request.get("https://api.example.com/data"))
  .map(_.contentAsString)
  .subscribe { content =>
    println(s"Received: ${content}")
  }

Key Features

  • Cross-Platform - Works on JVM, Scala.js, and Scala Native
  • Automatic Retry - Built-in retry with exponential backoff
  • Streaming - Stream response bodies as byte chunks
  • Reactive - Async client returns Rx[HttpResponse]
  • Configurable - Timeouts, retries, headers

Client Types

TypeMethodUse Case
SyncnewSyncClientSimple blocking requests
AsyncnewAsyncClientNon-blocking with Rx

Package

scala
import wvlet.uni.http.*

Released under the Apache 2.0 License.