ollls / zio-tls-http   2.0.1

MIT License GitHub

100% non-blocking, Java NIO only( inspired by zio-nio) , JSON HTTP server based on Scala ZIO library. Everything including TLS encryption modeled as ZIO effects, convenient route DSL similar to https4s, up to 30K TPS local JSON transaction with 25 threads on 6 cores(i7) with ZIO fibers.

Scala versions: 3.x

Generic badge Generic badge Generic badge
Generic badge

Lightweight Scala TLS HTTP 1.1 Web Server based on ZIO async fibers and Java NIO sockets.

Web Server has its own implementation of TLS protocol layer based on JAVA NIO and standard JDK SSLEngine. Everything is modeled as ZIO effects and processed as async routines with Java NIO. Java NIO and Application ZIO space uses same thread pool for non-blocking operations. Server implements a DSL for route matching, it's very similar (but a bit simplified) to the one which is used in HTTP4s. Server implements pluggable pre-filters and post-filters. The goal is to provide small and simple HTTP JSON server with all the benefits of async monadic non-blocking JAVA NIO calls wrapped up into ZIO interpreter with minimal number of dependencies.

Our new HTTP/2 server can talk HTTP/1.1 now!
Please, check it out. Simplified, streamlined, massivley parallel with nothing but ZIO Streams and HTTP/2, for client and server. HTTP/2 client available as ZIO Service.
https://github.com/ollls/zio-quartz-h2

ZIO2 release.

Necessary dependencies(check hello-http template):

   "dev.zio" %% "zio" % "2.0.x",
   "io.github.ollls" %% "zio-tls-http" % "2.0.0",
  • Native ZStream2 with ZIO2.
  • Integration with http1.1 chunked.
  • Special http multi-part ZStream.
  • Support for ZIO2 logging with logback.
  • Separate http access log with rotation.
  • App template: "hello-http" with major use cases.
  • Version of ZIO library can be configured in build.sbt on app template by the user.

Appreciate any feedback, please use, my email or open issue, or use https://discord.com/channels/629491597070827530/817042692554489886 ( #zio-tls-http )

Also: Please check out https://github.com/ollls/quartz-h2 https://github.com/ollls/zio-quartz-h2

To run from sbt: "sbt example/run".
Example file: https://github.com/ollls/zio-tls-http/blob/master_zio2/examples/start/src/main/scala/MyServer.scala

package example
import zio.logging.backend.SLF4J
import zio.{ZIO, Chunk}
import zhttp.Method._
import zhttp.dsl._
import zhttp.{TLSServer, TcpServer, HttpRoutes}
import zhttp.{MultiPart, Headers, ContentType, Response, FileUtils}

object MyApp extends zio.ZIOAppDefault {

  override val bootstrap =
    zio.Runtime.removeDefaultLoggers ++ SLF4J.slf4j ++ zio.Runtime.enableWorkStealing
    
  val r = HttpRoutes.of { case GET -> Root / "health" =>
    ZIO.attempt(Response.Ok().asTextBody("Health Check Ok"))
  }
  val myHttp =
    new TcpServer[Any](port = 8080, keepAlive = 2000, serverIP = "0.0.0.0")
  val run = myHttp.run(r)
}

To enable more detailed logging, use logback-test.xml with "debug" or "trace" levels

  <root level="debug">
    <appender-ref ref="STDOUT" />
  </root>