AlexandreRoba / zio-http

A scala library to write Http apps.

Home Page:https://dream11.github.io/zio-http

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

Check out the full documentation here: Documentation

Continuous Integration Discord Chat Sonatype Nexus (Releases) Sonatype Nexus (Snapshots) Average time to resolve an issue Open in Visual Studio Code

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 -> !! / "text" => Response.text("Hello World!")
  }

  override def run(args: List[String]): URIO[zio.ZEnv, ExitCode] =
    Server.start(8090, app).exitCode
}

Examples

You can checkout more examples in the example project —

Steps to run an example

  1. Edit the RunSettings - modify className to the example you'd like to run.
  2. From sbt shell, run ~example/reStart. You should see Server started on port: 8090.
  3. Send curl request for defined http Routes, for eg : curl -i "http://localhost:8090/text" for example.HelloWorld.

Installation

Setup via build.sbt

libraryDependencies += "io.d11" %% "zhttp"      % "[version]"
libraryDependencies += "io.d11" %% "zhttp-test" % "[version]" % Test

NOTE: ZIO Http is compatible with ZIO 1.x and ZIO 2.x.

Watch Mode

You can use the sbt-revolver plugin to start the server and run it in watch mode using ~ reStart command on the SBT console.

About

A scala library to write Http apps.

https://dream11.github.io/zio-http

License:MIT License


Languages

Language:Scala 100.0%