Skip to content

Commit 7f9521c

Browse files
authored
zio-http update (#6915)
* zio-http update * zio-http update #1 * zio-http update #3 --------- Co-authored-by: whiplash <[email protected]>
1 parent 70ba394 commit 7f9521c

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

scala/zio-http/build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
val ZioHttpVersion = "[3.0.0-RC1,3.1.0)"
1+
val ZioHttpVersion = "3.0.0-RC3"
22

33
name := "server"
44

scala/zio-http/src/main/scala/Main.scala

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
import zio._
22
import zio.http._
3+
import zio.http.codec.PathCodec.string
34

45
object HelloWorld extends ZIOAppDefault {
56

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

12+
val y = Method.GET / "" -> handler(Response.ok)
13+
14+
val z = Method.POST / "user" -> handler(Response.ok)
15+
16+
val app = Routes(x, y, z).toHttpApp
17+
1218
override val run =
1319
Server.serve(app).provide(Server.defaultWithPort(3000))
1420

0 commit comments

Comments
 (0)