Supports ZIO v2.0.0-RC2
Highlights
-
Support for Static Server
ZIO-HTTP now provides support for building static servers with a very simple DSL.// A simple app to serve static resource files from a local directory. val app = Http.collectHttp[Request] { case Method.GET -> "static" /: path => for { file <- Http.getResourceAsFile(path.encode) http <- // Rendering a custom UI to list all the files in the directory if (file.isDirectory) { // Accessing the files in the directory val files = file.listFiles.toList.sortBy(_.getName) val base = "/static" val rest = path.dropLast(1) // Custom UI to list all the files in the directory Http.template(s"File Explorer ~$base${path}") { ul( li(a(href := s"$base$rest", "..")), files.map { file => li( a( href := s"$base${path.encode}${if (path.isEnd) file.getName else "/" + file.getName}", file.getName, ), ) }, ) } } // Return the file if it's a static resource else if (file.isFile) Http.fromFile(file) // Return a 404 if the file doesn't exist else Http.empty } yield http }
-
New
Http.attempt
operator
Attempts to create an Http that succeeds with the provided value, capturing all exceptions on it's way.val app = Http.attempt(throw throwable).execute(())
💥 Breaking Changes
- Rename
provide
andprovideSome
inHttp
andSocket
domainsPrevious Current provide
provideEnvironment
provideSome
provideSomeEnvironment
🚀 Features
- Feature: Static Server @tusharmath (#1061)
- Feature: Support custom
ChannelInitializer
@rajcspsg (#932) - Feature: add
ifModifiedSinceDecoded
@tusharmath (#1075) - Feature: add
getResource
andgetResourceAsFile
operators on Http @tusharmath (#1074) - Feature: add
Http.attempt
operator @tusharmath (#1070) - Feature: add
withMediaType
operator inHeaderModifier
@tusharmath (#1071) - Feature: add
foldCause
to HttpError @tusharmath (#1066) - Feature: add
code
method on Status @tusharmath (#1068) - Feature: add
dropLast
to Path @tusharmath (#1065) - Feature: Add
data
inRequest
trait @amitksingh1490 (#1017) - Feature: add
Http.fromResource
@tusharmath (#1009) - Feature: add
fromFileZIO
@tusharmath (#1010) - Feature: Http from HExit @dinojohn (#986)
- Feature:
Content-Type
should be set using a custom MimeDB @ashprakasan (#899) - Feature:
Response.html
support taking in aStatus
@tusharmath (#1067)
Improvements
- Refactor: Remove tuple from ResponseHandler @amitksingh1490 (#1033)
- Refactor: Content Type Fixes @tusharmath (#1008)
- Refactor:
fromFile
usesfromFileZIO
@tusharmath (#1011) - Refactor: Tail recursive path encode method @ShrutiVerma97 (#1035)
- Refactor: Remove Collect and FromFunctionZIO @dinojohn (#1002)
- Refactor: rename
provide
andprovideSome
@girdharshubham (#996) - Performance: Use
CharSequence
for ServerTime @tusharmath (#1064)
🐛 Bug Fixes
- Fix: type info of
Http.response
@tusharmath (#1073) - Fix: Releasing request twice @dinojohn (#1046)
- Fix: Binary WebSocketFrame @girdharshubham (#1005)
🧰 Maintenance
- Maintenance: run scalafmt once @girdharshubham (#1027)
- Update scalafmt-core to 3.4.3 @amitksingh1490 (#1022)
- Update sbt-bloop to 1.4.13 @amitksingh1490 (#1055)
- Update jwt-core to 9.0.4 @amitksingh1490 (#1056)
Full Changelog: v2.0.0-RC3...v2.0.0-RC4