import zio.http._
import zio.http.Server
import zio.stream.ZStream
import zio._
import java.io.File
import java.nio.file.Paths
object FileStreaming extends App {
val app = Http.collectHttp[Request] {
case Method.GET -> !! / "health" => Http.ok
case Method.GET -> !! / "blocking" => Http.fromStream(ZStream.fromFile(Paths.get("README.md")))
case Method.GET -> !! / "video" => Http.fromFile(new File("src/main/resources/TestVideoFile.mp4"))
case Method.GET -> !! / "text" => Http.fromFile(new File("src/main/resources/TestFile.txt"))
}
override def run(args: List[String]): URIO[zio.ZEnv, ExitCode] =
Server.start(8090, app.silent).exitCode
}