Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scala/zio-http/build.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
val ZioHttpVersion = "[3.0.0-RC1,3.1.0)"
val ZioHttpVersion = "3.0.0-RC3"

name := "server"

Expand Down
14 changes: 10 additions & 4 deletions scala/zio-http/src/main/scala/Main.scala
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
import zio._
import zio.http._
import zio.http.codec.PathCodec.string

object HelloWorld extends ZIOAppDefault {

val app = Http.collect[Request] {
case Method.GET -> Root => Response.ok
case Method.POST -> Root / "user" => Response.ok
case Method.GET -> Root / "user" / id => { Response.text(id) }
val x = Method.GET / "user" / string("id") -> handler {
(id: String, _: Request) =>
Response.text(s"$id")
}

val y = Method.GET / "" -> handler(Response.ok)

val z = Method.POST / "user" -> handler(Response.ok)

val app = Routes(x, y, z).toHttpApp

override val run =
Server.serve(app).provide(Server.defaultWithPort(3000))

Expand Down