ZIO Http
ZIO Http is a scala library for building http apps. It is powered by ZIO and netty and aims at being the defacto solution for writing, highly scalable and performant web applications using idiomatic scala.
Table of Contents
Getting Started
A simple Http server can be built using a few lines of code.
import zio._
import zhttp.http._
import zhttp.service.Server
object HelloWorld extends App {
val app = Http.collect[Request] {
case Method.GET -> Root / "text" => Response.text("Hello World!")
}
override def run(args: List[String]): URIO[zio.ZEnv, ExitCode] =
Server.start(8090, app).exitCode
}
Installation
Setup via build.sbt
libraryDependencies += "io.d11" %% "zhttp" % "[version]"
Benchmarks
These are some basic benchmarks of how ZIO Http performs wrt other main-stream libraries.
Benchmark (req/sec) | json |
plain-text |
---|---|---|
ZIO-Http | 700073.31 | 719576.04 |
Vert.x | 644854.27 | 707991.69 |
Finagle | 567496.97 | 572231.69 |
Play | 261223.68 | 263819.25 |
Http4s | 135565.22 | 139573.98 |
More details are available here.