v1.0.0.0-RC18
github-actions
released this
09 Dec 11:54
·
1240 commits
to main
since this release
Changes
Highlights
This release packs server-side cookie support, middleware support and endpoints to make your apis typesafe.
Server Side Cookie Support
private val cookie = Cookie("org", "d11") @@ maxAge(5 seconds)
val res = Response.ok.addCookie(cookie)
private val app = Http.collect[Request] {
case Method.GET -> !! / "cookie" =>
Response.ok.addCookie(cookie @@ path(!! / "cookie") @@ httpOnly)
case Method.GET -> !! / "secure-cookie" =>
Response.ok.addCookie(cookie @@ secure @@ path(!! / "secure-cookie"))
case Method.GET -> !! / "cookie" / "remove" =>
res.addCookie(cookie.clear)
}
Middleware Support
val app: HttpApp[Clock, Nothing] = Http.collectM[Request] {
// this will return result instantly
case Method.GET -> !! / "text" => ZIO.succeed(Response.text("Hello World!"))
// this will return result after 5 seconds, so with 3 seconds timeout it will fail
case Method.GET -> !! / "long-running" => ZIO.succeed(Response.text("Hello World!")).delay(5 seconds)
}
val serverTime: Middleware[Clock, Nothing] = patchM((_, _) =>
for {
currentMilliseconds <- currentTime(TimeUnit.MILLISECONDS)
withHeader = Patch.addHeaders(List(Header("X-Time", currentMilliseconds.toString)))
} yield withHeader,
)
val middlewares: Middleware[Console with Clock, IOException] =
// print debug info about request and response
debug ++
// close connection if request takes more than 3 seconds
timeout(3 seconds) ++
// add static header
addHeader("X-Environment", "Dev") ++
// add dynamic header
serverTime
Server.start(8090, (app @@ middlewares).silent).exitCode
Typesafe Endpoint Support
def app = GET / "a" / *[Int] / "b" / *[Boolean] to { a =>
Response.text(a.params.toString)
}
🚀 Features
finalFragment
flag for WebSocketFrame @morozov11 (#393)ifThenElse
method in HttpMiddleware @dinojohn (#485)fromFunctionM
in HttpApp @dinojohn (#486)- Cookie Support @ShrutiVerma97 (#277)
- Http Middleware @tusharmath (#403)
- Add IOUring support @madper (#382)
- Typesafe Endpoints @kaushik143 (#367)
- Authentication middleware @dinojohn (#506)
- URL fragment @soujiro32167 (#397)
- Http 100 continue @ShrutiVerma97 (#489)
- Websocket Enhancements @tusharmath (#433)
- Added APIs from main @ShrutiVerma97 (#406)
- Decode content @dinojohn (#381)
- Make path extraction right associative @tusharmath (#337)
- Charset handling in request @ShrutiVerma97 (#287)
- Add start overloads @smehta91 (#329)
- Added helper for text/html and text/yaml @tdrozdowski (#327)
- Add basic request testing util @whiskeylips (#308)
- Add helpers for redirect methods. @whiskeylips (#305)
- Http Enhancements @tusharmath (#301)
- Add optional remoteAddress to Request @jakubjanecek (#264)
- SSL: Server & Client @dinojohn (#256)
- Use implicit class for HttpApp syntax @frekw (#266)
- Add request meta Info in ContentDecoder @amitksingh1490 (#505)
- Add tap* combinators @frekw (#273)
- Merge HttpEndPoint and HttpApp @amitksingh1490 (#363)
- Added provideLayer methods @ShrutiVerma97 (#364)
- Added methods from Http in HttpApp @ShrutiVerma97 (#371)
- Add endpoint method @kaushik143 (#396)
Improvements
- Use Option instead of Either in Cookies @jgoday (#541)
- Add toApp, toResponse methods to status @jgoday (#577)
- Dependencies moved to Dependencies.scala @girdharshubham (#388)
- Fixed https client tests @ShrutiVerma97 (#278)
- Constructor for FromStream @dinojohn (#297)
- Wrap HttpApp around Http @dinojohn (#254)
- And type param to ContentDecoder for input type @tusharmath (#375)
- Remove AliasModule @dinojohn (#316)
- Sticky Threads @tusharmath (#303)
- URL builder performance @tusharmath (#302)
- Clean up @tusharmath (#591)
- Decoder Cleanup @tusharmath (#536)
- Making HttpApp a type-alias to Http @tusharmath (#531)\
- Restructure Handler @tusharmath (#530)
- Add operators to HttpApp to modify Requests and Response @tusharmath (#516)
- Rewrite CORS to use new middleware API @rpiotrow (#452)
- Replaced comma with plus @ShrutiVerma97 (#368)
- Move compile in HttpApp to separate module @amitksingh1490 (#374)
- Added comment for converting CompositeByteBuf to array @ShrutiVerma97 (#395)
🐛 Bug Fixes
- HttpApp write response only once @tusharmath (#387)
- Route matching with encoded paths @ShrutiVerma97 (#323)
- Added timeout and flaky in test @ShrutiVerma97 (#314)
- Allow multiple headers same type @amitksingh1490 (#285)
- Basic auth header fixed @ShrutiVerma97 (#271)
- Query parameters being ignored in client requests @Adriani-Furtado (#268)
- AuthMiddleware @dinojohn (#597)
- Build @amitksingh1490 (#372)
- HttpApp write response only once @tusharmath (#387)
- Link to WebSocket Server @sheldonjms (#335)
- Scaladoc Doc generation failing @amitksingh1490 (#596)
- Backpressure Example @ShrutiVerma97 (#548)
- Do not ignore query params when url path is empty @kaushik143 (#529)
- MultipleDecode method in cookie @ShrutiVerma97 (#459)
- Fix for self signed certificate in SSLSpec @dinojohn (#432)
🧰 Maintenance
- Release Fixes @tusharmath (#522)
- Update #470 @tusharmath (#482)
- Scoverage with Codecov @girdharshubham (#487)
- Revert deleted methods in HttpApp @ShrutiVerma97 (#377)
- Documentation website and CI @smehta91 (#465)
- Dependencies moved to Dependencies.scala @girdharshubham (#388)
- Remove content-decoder @tusharmath (#575)
- Benchmarking Workflow @amitksingh1490 (#532)
- Order for clean up changed @girdharshubham (#561)
- Release/next @tusharmath (#357)
- Scala 2.12 type error @amitksingh1490 (#389)
- Sticky Threads @tusharmath (#303)
- Marked test as flaky @ShrutiVerma97 (#296)
- Provide removed from HttpApp @girdharshubham (#429)
📓 Documentation and Examples
- Fix examples @ayakovlenko (#320)
- Backpressure example fixed @ShrutiVerma97 (#514)
- Https server example @dinojohn (#481)
- Update README.md @tusharmath (#289)
- Example of middleware usage @rpiotrow (#444)
- Add example package @kaushik143 (#507)
- Add documentation for requests @whiskeylips (#309)
- Fixed endpoint example (#603)
📈 Version Bumps
- Update netty-all to 4.1.70.Final @amitksingh1490 (#469)
- Update sbt-scalafmt to 2.4.5 @amitksingh1490 (#590)
- Update scalafmt-core to 3.2.1 @amitksingh1490 (#587)
- Update scala-library to 2.13.7 @amitksingh1490 (#463)
- Update scala-library to 2.12.15 @scala-steward (#352)
- Update sbt-scalafix to 0.9.32 @amitksingh1490 (#520)
- Update scala3-library to 3.1.0 @scala-steward (#404)
- Update sbt-bloop to 1.4.11 @amitksingh1490 (#466)
- Update jwt-core to 9.0.2 @amitksingh1490 (#439)
- Update sbt-scala3-migrate to 0.4.6 @amitksingh1490 (#400)
- Update scala-collection-compat to 2.6.0 @amitksingh1490 (#478)
- Update sbt-ci-release to 1.5.10 @amitksingh1490 (#401)
- Update sbt to 1.5.5 @scala-steward (#293)
- Update sbt-github-actions to 0.13.0 @scala-steward (#324)
- Update sbt-updates to 0.6.0 @scala-steward (#318)
- Update zio, zio-streams, zio-test, ... to 1.0.12 @scala-steward (#356)
- Update netty-incubator-transport-native-io_uring to 0.0.10.Final @amitksingh1490 (#472)