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
@@ -39,10 +39,10 @@ object Example extends cask.MainRoutes:
39
39
{% endtab %}
40
40
{% endtabs %}
41
41
42
-
The example above creates an endpoint, returning the current date and time available at `/time`. The exact response will be
42
+
The example above creates an endpoint that returns the current date and time available at `/time`. The exact response will be
43
43
recreated every time you refresh the webpage.
44
44
45
-
Since the endpoint method has the `String` output type, the result will be sent with `text/plain`[content type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type).
45
+
Since the endpoint method has the `String` output type, the result will be sent with the `text/plain`[content type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type).
46
46
If you want an HTML output to be interpreted by the browser, you will need to set the `Content-Type` header manually
47
47
or [use the Scalatags templating library](/toolkit/web-server-dynamic.html#using-html-templates), supported by Cask.
48
48
@@ -132,7 +132,7 @@ In the example above, the `:city` segment in `/time/:city` is available through
132
132
The name of the argument must be identical to the segment name. The `getZoneIdForCity` helper method finds the timezone for
133
133
a given city, and then the current date and time are translated to that timezone.
134
134
135
-
Accessing the endpoint at[http://localhost:8080/time/Paris](http://localhost:8080/time/Paris) will result in:
135
+
Accessing the endpoint at[http://localhost:8080/time/Paris](http://localhost:8080/time/Paris) will result in:
136
136
```
137
137
Current date is: 2024-07-22T09:08:33.806259+02:00[Europe/Paris]
138
138
```
@@ -143,7 +143,7 @@ Consult the [documentation](https://com-lihaoyi.github.io/cask/index.html#variab
143
143
144
144
## Using HTML templates
145
145
146
-
To create an HTML response, you can combine Cask code with the [Scalatags](https://com-lihaoyi.github.io/scalatags/) templating library.
146
+
To create an HTML response, you can combine Cask with the [Scalatags](https://com-lihaoyi.github.io/scalatags/) templating library.
@@ -78,15 +78,15 @@ object Example extends cask.MainRoutes:
78
78
{% endtabs %}
79
79
80
80
In this example we create a form asking for name and surname of a user and then redirect the user to a greeting page. Notice the
81
-
use of `cask.Response`. The `cask.Response` type allows user to set the status code, headers and cookies. The default
82
-
content type in case of `String` returning endpoint method is `text/plain`, set it to `text/html` in order for browser to display the form correctly.
81
+
use of `cask.Response`. The `cask.Response` type allows the user to set the status code, headers and cookies. The default
82
+
content type for an endpoint method returning a `String` is `text/plain`. Set it to `text/html` in order for the browser to display the form correctly.
83
83
84
-
The `formEndpoint` endpoint reads the form data using `name` and `surname` parameters. The names of parameters must
84
+
The `formEndpoint` endpoint reads the form data using the `name` and `surname` parameters. The names of parameters must
85
85
be identical to the field names of the form.
86
86
87
87
## Handling JSON-encoded input
88
88
89
-
JSON fields are handled in the same way as form fields, except that `cask.PostJson` annotation is used. The fields
89
+
JSON fields are handled in the same way as form fields, except that we use the `@cask.PostJson` annotation. The fields
Copy file name to clipboardExpand all lines: _overviews/toolkit/web-server-intro.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,9 +13,9 @@ Its main focus is on the ease of use, which makes it ideal for newcomers, at the
13
13
frameworks provide, like asynchronicity.
14
14
15
15
To define an endpoint it's enough to annotate a function with an annotation specifying the request path.
16
-
Cask allows for building the response manually using tools Cask library provides, specifying the content, headers,
17
-
status code, etc. An endpoint function can also just return a string, a [uPickle](https://com-lihaoyi.github.io/upickle/) JSON type, or a [Scalatags](https://com-lihaoyi.github.io/scalatags/)
18
-
template and Cask will automatically create a response, setting all the necessary headers.
16
+
Cask allows for building the response manually using tools that the library provides, specifying the content, headers,
17
+
status code, etc. An endpoint function can also return a string, a [uPickle](https://com-lihaoyi.github.io/upickle/) JSON type, or a [Scalatags](https://com-lihaoyi.github.io/scalatags/)
18
+
template. In that case, Cask will automatically create a response with the appropriate headers.
19
19
20
20
Cask comes bundled with the uPickle library for handling JSONs, supports WebSockets and allows for extending endpoints with
21
21
decorators, which can be used to handle authentication or rate limiting.
0 commit comments