github zio/zio-http v2.0.0-RC1
v2.0.0-RC1 - ZIO 2 Support

latest releases: v3.0.0-RC7, v3.0.0-RC6, v3.0.0-RC5...
2 years ago

This release supports ZIO 2.0.0-RC1.

Note: For some time, releases targeting ZIO 1 will be using the version 1.0.0.0-RCx, whereas releases targeting ZIO 2 will be using the version 2.0.0-RCx

Highlights

💥 Breaking Changes

  • Follow ZIO 2.0 naming conventions Example: CollectM => CollectZIO
private val app = Http.collectZIO[Request] {
  case Method.GET -> !! / "random" => random.nextString(10).map(Response.text(_))
  case Method.GET -> !! / "utc"    => clock.currentDateTime.map(s => Response.text(s.toString))
}
  • Removed Type Params from Response
  • Removed Type Params from SocketApp
  • Removed Type Params from HttpData
  • Renamed socket to fromSocket in Response
  • Removed @@ composition from cookie
    private val app = Http.collect[Request] {
        case Method.GET -> !! / "cookie" =>
          Response.ok.addCookie(cookie.withPath(!! / "cookie").withHttpOnly)
    }
  • Builder pattern for SocketApp
    private val fooBar = Socket.collect[WebSocketFrame] {
        case WebSocketFrame.Text("FOO") => ZStream.succeed(WebSocketFrame.text("BAR"))
      }
    
    private val socketApp = {
        SocketApp(fooBar) // Called after each message being received on the channel
          // Called after the request is successfully upgraded to websocket
          .onOpen(open)
          // Called after the connection is closed
          .onClose(_ => console.putStrLn("Closed!").ignore)
      }

✨ New APIs

  • Added wrapZIO operator on Response
    private val app =
        Http.collectZIO[Request] {
          case Method.GET -> !! / "greet" / name  => Response.text(s"Greetings ${name}!").wrapZIO
        }
  • Added toSocketApp and toResponse on Socket
      private val app =
        Http.collectZIO[Request] {
          case Method.GET -> !! / "subscriptions" => socketApp.toResponse
        }
      
  • Added collectHttp on Http
    val app = Http.collectHttp[Request] {
    // Read the file as ZStream
    // Uses the blocking version of ZStream.fromFile
    case Method.GET -> !! / "blocking" => Http.fromStream(ZStream.fromFile(Paths.get("README.md")))
    }
  • Added provide on SocketApp

Changes

🚀 Features

Improvements

🐛 Bug Fixes

🧰 Maintenance

Thanks to @adamfraser, @kitlangton and @jdegoes for the work on ZIO 2 support!

New Contributors

Full Changelog: v1.0.0.0-RC21...v2.0.0-RC1

Don't miss a new zio-http release

NewReleases is sending notifications on new releases.