You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So we start by creating a new RhoService which will be converted to an HttpService later. This RhoService will contain our api endpoints. Every api endpoint starts (optionally) with a description for that endpoint and then the implementation. We describe the HTTP method (GET/POST/DELETE etc) and then an implementation for the url endpoint.
17
+
So we start by creating a new RhoService which will be converted to an HttpService later. This RhoService will contain our api endpoints. Every api endpoint starts (optionally, for Swagger) with a description for that endpoint and then the implementation. We describe the HTTP method (GET/POST/DELETE etc) and then an implementation for the url endpoint.
18
18
19
19
You can specify and capture path or query parameters in your path. You specify a name and description (optional) for the variables. The available types that you can capture are:
20
20
- all primitive types
21
-
- java.util.Date (yyyy-MM-dd)
22
-
- java.util.UUID
23
-
- java.time.Instant (yyyy-MM-ddThh:mm:ssZ)
21
+
-`java.util.Date` (yyyy-MM-dd)
22
+
-`java.util.UUID`
23
+
-`java.time.Instant` (yyyy-MM-ddThh:mm:ssZ)
24
24
25
25
Checkout these methods:
26
26
-`pathVar` functions for capturing path variables
27
27
-`param` functions for capturing query parameters
28
28
-`capture` functions for capturing headers
29
29
30
+
Think of `|>>` as a function that "registers" new route matcher and associated action in RhoService.
31
+
Route matcher is at lefthand-side (represented as `TypedBuilder`) and action at righthand-side is a function returning HTTP response.
32
+
The arguments for action appear exactly as they do in the URL spec (route matcher).
33
+
So in the sample above, `someInt` is first then `name` and so on. Optionally it can accept whole `org.http4s.Request` as first argument.
30
34
31
-
Think of `|>>` as a function from url specification to an implementation which returns a Response. The arguments for `|>>` appear exactly as they do in the url spec. So in the sample above, `someInt` is first then `name` and so on.
35
+
Apart from plain URL parameters and path, you can insert header captures and body decoders for your requests, an example:
32
36
33
-
You can insert header captures and body decoders for your requests, an example:
Also, in example above, we are specifying that the body is a json object for some `T`.
44
62
Anything that has a `EntityDecoder` can be specified as a body decoder. In the example above `jsonOf` is an `EntityDecoder` provided by `circe`. Included decoders in Rho are:
45
63
- binary
46
64
- binaryChunk
@@ -59,6 +77,8 @@ case class MyClass(name: String, description: String, someBool: Boolean, tags: L
0 commit comments