Skip to content

Commit 4d4264f

Browse files
committed
Grammar fixes
1 parent 569d5df commit 4d4264f

8 files changed

+33
-33
lines changed

_includes/_markdown/install-cask.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{% tabs cask-install class=tabs-build-tool %}
44

55
{% tab 'Scala CLI' %}
6-
You can declare dependency on Cask with `using` directive:
6+
You can declare a dependency on Cask with the following `using` directive:
77
```scala
88
//> using dep "com.lihaoyi::cask::0.9.2"
99
```

_overviews/toolkit/web-server-cookies-and-decorators.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ next-page:
1414
Cookies are saved by adding them to the `cookies` parameter of the `cask.Response` constructor.
1515

1616
In this example, we are building a rudimentary authentication service. The `getLogin` method provides a form where
17-
username and password can be inputted. The `postLogin` reads the credentials and, if they match the expected ones, a session
18-
identifier is generated, saved in the application state, and sends back a cookie with the identifier.
17+
the user can enter their username and password. The `postLogin` method reads the credentials. If they match the expected ones, it generates a session
18+
identifier is generated, saves it in the application state, and sends back a cookie with the identifier.
1919

20-
Cookies can be read either with a method parameter of `cask.Cookie` type or by accessing `cask.Request` directly.
20+
Cookies can be read either with a method parameter of `cask.Cookie` type or by accessing the `cask.Request` directly.
2121
If using the former method, the names of parameters have to match the names of cookies. If a cookie with a matching name is not
2222
found, an error response will be returned. In the `checkLogin` function, the former method is used, as the cookie is not
2323
present before the user logs in.
@@ -142,7 +142,7 @@ object Example extends cask.MainRoutes:
142142
## Using decorators
143143

144144
Decorators can be used for extending endpoints functionality with validation or new parameters. They are defined by extending
145-
`cask.RawDecorator` class and then used as annotations.
145+
`cask.RawDecorator` class. They are used as annotations.
146146

147147
In this example, the `loggedIn` decorator is used to check if the user is logged in before accessing the `/decorated`
148148
endpoint.

_overviews/toolkit/web-server-dynamic.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ next-page: web-server-query-parameters
1111

1212
## Serving dynamically generated content
1313

14-
You can create an endpoint returning dynamically generated content with `@cask.get` annotation.
14+
You can create an endpoint returning dynamically generated content with the `@cask.get` annotation.
1515

1616
{% tabs web-server-dynamic-1 class=tabs-scala-version %}
1717
{% tab 'Scala 2' %}
@@ -39,10 +39,10 @@ object Example extends cask.MainRoutes:
3939
{% endtab %}
4040
{% endtabs %}
4141

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
4343
recreated every time you refresh the webpage.
4444

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).
4646
If you want an HTML output to be interpreted by the browser, you will need to set the `Content-Type` header manually
4747
or [use the Scalatags templating library](/toolkit/web-server-dynamic.html#using-html-templates), supported by Cask.
4848

@@ -132,7 +132,7 @@ In the example above, the `:city` segment in `/time/:city` is available through
132132
The name of the argument must be identical to the segment name. The `getZoneIdForCity` helper method finds the timezone for
133133
a given city, and then the current date and time are translated to that timezone.
134134

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:
136136
```
137137
Current date is: 2024-07-22T09:08:33.806259+02:00[Europe/Paris]
138138
```
@@ -143,7 +143,7 @@ Consult the [documentation](https://com-lihaoyi.github.io/cask/index.html#variab
143143

144144
## Using HTML templates
145145

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.
147147

148148
Import the Scalatags library:
149149

_overviews/toolkit/web-server-input.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ next-page: web-server-websockets
1111

1212
## Handling form-encoded input
1313

14-
To create an endpoint that handles the data provided in an HTML form, use `cask.postForm` annotation, give the endpoint method arguments
14+
To create an endpoint that handles the data provided in an HTML form, use the `@cask.postForm` annotation. Add arguments to the endpoint method
1515
with names corresponding to names of fields in the form and set the form method to `post`.
1616

1717
{% tabs web-server-input-1 class=tabs-scala-version %}
@@ -78,15 +78,15 @@ object Example extends cask.MainRoutes:
7878
{% endtabs %}
7979

8080
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.
8383

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
8585
be identical to the field names of the form.
8686

8787
## Handling JSON-encoded input
8888

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
9090
will be read into the endpoint method arguments.
9191

9292
{% tabs web-server-input-2 class=tabs-scala-version %}
@@ -130,9 +130,9 @@ Hello John Smith
130130

131131
The endpoint will accept JSONs that have only the fields with names specified as the endpoint method arguments. If there
132132
are more fields than expected, some fields are missing or have an incorrect data type, an error message
133-
will be returned with 400 response code.
133+
will be returned with the response code 400.
134134

135-
To handle the case when the fields of the JSON are not known in advance, you can use argument with the `ujson.Value` type
135+
To handle the case when the fields of the JSON are not known in advance, you can use an argument with the `ujson.Value` type,
136136
from uPickle library.
137137

138138
{% tabs web-server-input-3 class=tabs-scala-version %}

_overviews/toolkit/web-server-intro.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ Its main focus is on the ease of use, which makes it ideal for newcomers, at the
1313
frameworks provide, like asynchronicity.
1414

1515
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.
1919

2020
Cask comes bundled with the uPickle library for handling JSONs, supports WebSockets and allows for extending endpoints with
2121
decorators, which can be used to handle authentication or rate limiting.

_overviews/toolkit/web-server-query-parameters.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ sorting or limiting the results provided by the server. For example, in the `<ho
1414
is the name of a parameter, and `Paris` is its value. Cask allows for reading the query parameters by defining an endpoint
1515
method with arguments matching the names of the expected parameters and not matching any of the URL segments.
1616

17-
In this example, the `city` parameter will be optional, which you specify in Cask by giving the argument `Option` type and
18-
`None` default value. If not provided, the time for the current timezone will be returned.
17+
In this example, we give an `Option` type and the default value `None` to the `city` parameter. This tells Cask that it is optional.
18+
If not provided, the time for the current timezone will be returned.
1919

2020
{% tabs web-server-query-1 class=tabs-scala-version %}
2121
{% tab 'Scala 2' %}

_overviews/toolkit/web-server-static.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ next-page: web-server-dynamic
1212
## Serving a static file
1313

1414
An endpoint is a specific URL where a particular webpage can be accessed. In Cask, an endpoint is a function returning the
15-
webpage data together with an annotation describing the URL it's available at.
15+
webpage data, together with an annotation describing its URL.
1616

17-
To create a static file serving endpoint, we need two things: an HTML file with the page content and a function that
18-
points out the location of the file.
17+
To create an endpoint serving static files, we need two things: an HTML file with the page content and a function that
18+
points to that file.
1919

2020
Create a minimal HTML file named `hello.html` with the following contents.
2121

@@ -65,7 +65,7 @@ example
6565
{% endtabs %}
6666

6767
The `@cask.staticFiles` annotation specifies at which path the webpage will be available. The endpoint function returns
68-
the location in which the file can be found.
68+
the location of the file.
6969

7070
{% tabs web-server-static-2 class=tabs-scala-version %}
7171
{% tab 'Scala 2' %}
@@ -93,9 +93,9 @@ In the example above, `@cask.staticFiles` instructs the server to look for files
9393
`src/main/resources` directory. Cask will match any subpath coming after `/static` and append it to the directory path.
9494
If you access the `/static/hello.html` file, it will serve the file available at `src/main/resources/hello.html`.
9595
The directory path can be any path available to the server, relative or not. If the requested file cannot be found in the
96-
specified location, a 404 response with an error message will be returned instead.
96+
specified location, the server will return a 404 response with an error message.
9797

98-
The `Example` object inherits from the `cask.MainRoutes` class, providing the main function that starts the server. The `initialize()`
98+
The `Example` object inherits from the `cask.MainRoutes` class. It provides the main function that starts the server. The `initialize()`
9999
method call initializes the server routes, i.e., the association between URL paths and the code that handles them.
100100

101101
### Using the resources directory
@@ -127,7 +127,7 @@ object Example extends cask.MainRoutes:
127127
{% endtabs %}
128128

129129
In the endpoint method, the location is set to `"."`, telling the server that the files are available directly in the
130-
resources directory. In general, you can use any nested location within the resources directory, for instance you could opt
130+
resources directory. In general, you can use any nested location within the resources directory. For instance, you could opt
131131
for placing your HTML files in the `static` directory inside the resources directory or using different directories to sort out
132132
files used by different endpoints.
133133

_overviews/toolkit/web-server-websockets.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ next-page: web-server-cookies-and-decorators
99

1010
{% include markdown.html path="_markdown/install-cask.md" %}
1111

12-
You can create a WebSocket endpoint by using the `@cask.websocket` annotation. The endpoint method can return either a
13-
`cask.WsHandler` instance defining how the communication should take place, or a `cask.Response`, which rejects the
12+
You can create a WebSocket endpoint with the `@cask.websocket` annotation. The endpoint method should return a
13+
`cask.WsHandler` instance defining how the communication should take place. It can also return a `cask.Response`, which rejects the
1414
attempt at forming a WebSocket connection.
1515

1616
The connection can also be closed by sending a `cask.Ws.close()` message through the WebSocket channel.
@@ -113,6 +113,6 @@ initialize()
113113
{% endtab %}
114114
{% endtabs %}
115115

116-
In the `cask.WsHandler` we define a `cask.WsActor` which reacts to events (of `cask.util.Ws.Event` type) and uses
117-
WebSocket channel to send messages. In this example, we receive the name of a city and return the current time there. If server
116+
In the `cask.WsHandler` we define a `cask.WsActor`. It reacts to events (of type `cask.util.Ws.Event`) and uses the
117+
WebSocket channel to send messages. In this example, we receive the name of a city and return the current time there. If the server
118118
receives an empty message, the connection is closed.

0 commit comments

Comments
 (0)