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
tofromSocket
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 Responseprivate val app = Http.collectZIO[Request] { case Method.GET -> !! / "greet" / name => Response.text(s"Greetings ${name}!").wrapZIO }
- Added
toSocketApp
andtoResponse
on Socketprivate val app = Http.collectZIO[Request] { case Method.GET -> !! / "subscriptions" => socketApp.toResponse }
- Added
collectHttp
on Httpval 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
- ZIO 2 support by @jdegoes in #809
- Feature: Added
updateHeader
toPatch
@ShrutiVerma97 (#779) - Feature: Return
Start
on server start @girdharshubham (#682) - Feature: CSRF Middleware @smehta91 (#761)
- Feature: Add
provide
operator on SocketApp @tusharmath (#763) - Feature: add middleware for CSRF handling @smehta91 (#542)
- Feature: Serve static files Asynchronously @ashprakasan (#706)
- Feature: add
setHeaders
toHeaderModifiers.scala
@tusharmath (#745)
Improvements
- Remove @@ feature for cookies @ShrutiVerma97 (#760)
🐛 Bug Fixes
- Fix: getSetCookieDecoded Method @ShrutiVerma97 (#777)
- Fix: Endpoint fix in
to
operator @sumawa (#749) - Response Json headers @amitksingh1490 (#750)
🧰 Maintenance
- Refactor: Use builder pattern for SocketApp @tusharmath (#762)
- Refactor: follow ZIO 2.0 naming conventions @tusharmath (#739)
- Refactor: Remove type params from HttpData @tusharmath (#766)
- Refactor: Add Response Handler @gciuloaica (#727)
- Update sbt-scala3-migrate to 0.5.0 @amitksingh1490 (#785)
- Refactor: Remove type params from Response @tusharmath (#772)
- Refactor: Remove error type from SocketApp @tusharmath (#769)
- Maintenance: remove twirl settings and examples @girdharshubham (#774)
- Scala doc generation CI step @girdharshubham (#771)
- Refactor: Remove type params from HttpData @tusharmath (#766)
- Refactor: follow ZIO 2.0 naming conventions @tusharmath (#739)
- Update scalafmt-core to 3.3.1 @amitksingh1490 (#744)
- Doc : update Readme.md with steps to start example server @ashprakasan (#748)
- Performance: Cookie decoder improvements @jgoday (#576)
- Update jwt-core to 9.0.3 @amitksingh1490 (#743)
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