File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change 1
- val ZioHttpVersion = " [ 3.0.0-RC1,3.1.0) "
1
+ val ZioHttpVersion = " 3.0.0-RC3 "
2
2
3
3
name := " server"
4
4
Original file line number Diff line number Diff line change 1
1
import zio ._
2
2
import zio .http ._
3
+ import zio .http .codec .PathCodec .string
3
4
4
5
object HelloWorld extends ZIOAppDefault {
5
6
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" )
10
10
}
11
11
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
+
12
18
override val run =
13
19
Server .serve(app).provide(Server .defaultWithPort(3000 ))
14
20
You can’t perform that action at this time.
0 commit comments