Skip to content

Commit

Permalink
if/else
Browse files Browse the repository at this point in the history
  • Loading branch information
Rishi Raj Jain committed Nov 23, 2023
1 parent ddf6f92 commit dd4ec9e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 20 deletions.
22 changes: 12 additions & 10 deletions docs/examples/advanced/fullstack-with-react-apps.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,23 @@ object ReactHelloWorld extends ZIOAppDefault {
if (req.url.path.toString == "/api/hello") {
Response.text("Hello World")
}
if (req.url.path.toString == "/") {
val file = new File(s"$buildDirectory/index.html")
val length = Headers(Header.ContentLength(file.length()))
Response(headers = length, body = Body.fromFile(file))
}
else {
val tmp = req.url.path.toString
val file = new File(s"$buildDirectory/$tmp")
val length = Headers(Header.ContentLength(file.length()))
Response(headers = length, body = Body.fromFile(file))
if (req.url.path.toString == "/") {
val file = new File(s"$buildDirectory/index.html")
val length = Headers(Header.ContentLength(file.length()))
Response(headers = length, body = Body.fromFile(file))
}
else {
val tmp = req.url.path.toString
val file = new File(s"$buildDirectory/$tmp")
val length = Headers(Header.ContentLength(file.length()))
Response(headers = length, body = Body.fromFile(file))
}
}
}
}
}.toHttpApp

// Run it like any simple app
val run = Server.serve(app).provide(Server.default)
}
Expand Down
1 change: 1 addition & 0 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ object Dependencies {

val zio = "dev.zio" %% "zio" % ZioVersion
val `zio-cli` = "dev.zio" %% "zio-cli" % ZioCliVersion
val `zio-http` = "dev.zio" %% "zio-http" % ZioVersion
val `zio-streams` = "dev.zio" %% "zio-streams" % ZioVersion
val `zio-schema` = "dev.zio" %% "zio-schema" % ZioSchemaVersion
val `zio-schema-json` = "dev.zio" %% "zio-schema-json" % ZioSchemaVersion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,23 @@ object ReactHelloWorld extends ZIOAppDefault {
if (req.url.path.toString == "/api/hello") {
Response.text("Hello World")
}
if (req.url.path.toString == "/") {
val file = new File(s"$buildDirectory/index.html")
val length = Headers(Header.ContentLength(file.length()))
Response(headers = length, body = Body.fromFile(file))
}
else {
val tmp = req.url.path.toString
val file = new File(s"$buildDirectory/$tmp")
val length = Headers(Header.ContentLength(file.length()))
Response(headers = length, body = Body.fromFile(file))
if (req.url.path.toString == "/") {
val file = new File(s"$buildDirectory/index.html")
val length = Headers(Header.ContentLength(file.length()))
Response(headers = length, body = Body.fromFile(file))
}
else {
val tmp = req.url.path.toString
val file = new File(s"$buildDirectory/$tmp")
val length = Headers(Header.ContentLength(file.length()))
Response(headers = length, body = Body.fromFile(file))
}
}
}
}
}.toHttpApp

// Run it like any simple app
val run = Server.serve(app).provide(Server.default)
}

0 comments on commit dd4ec9e

Please sign in to comment.