@@ -56,7 +56,7 @@ pub mut:
56
56
pub struct App {
57
57
pub:
58
58
// In the app struct we store data that should be accessible by all endpoints.
59
- // For example a database or configuration values.
59
+ // For example, a database or configuration values.
60
60
secret_key string
61
61
}
62
62
@@ -122,7 +122,7 @@ pub fn (app &App) create_product(mut ctx Context) vweb.Result {
122
122
}
123
123
```
124
124
125
- By default endpoints are marked as GET requests only. It is also possible to
125
+ By default, endpoints are marked as GET requests only. It is also possible to
126
126
add multiple HTTP verbs per endpoint.
127
127
128
128
** Example:**
@@ -185,7 +185,7 @@ If you want multiple parameters in your route and if you want to parse the param
185
185
yourself, or you want a wildcard route, you can add ` ... ` after the ` : ` and name,
186
186
e.g. ` @['/:path...'] ` .
187
187
188
- This will match all routes after ` '/' ` . For example the url ` /path/to/test ` would give
188
+ This will match all routes after ` '/' ` . For example, the url ` /path/to/test ` would give
189
189
` path = '/path/to/test' ` .
190
190
191
191
``` v ignore
@@ -202,8 +202,8 @@ You have direct access to query values by accessing the `query` field on your co
202
202
You are also able to access any formdata or files that were sent
203
203
with the request with the fields ` .form ` and ` .files ` respectively.
204
204
205
- In the following example, visiting http://localhost:port/user?name=Vweb we
206
- will see the text ` Hello Vweb ! ` . And if we access the route without the ` name ` parameter,
205
+ In the following example, visiting http://localhost:port/user?name=vweb we
206
+ will see the text ` Hello vweb ! ` . And if we access the route without the ` name ` parameter,
207
207
http://localhost:port/user , we will see the text ` no user was found ` ,
208
208
209
209
** Example:**
@@ -249,7 +249,7 @@ host in one app struct.
249
249
250
250
### Route Matching Order
251
251
252
- Vweb will match routes in the order that you define endpoints.
252
+ vweb will match routes in the order that you define endpoints.
253
253
254
254
** Example:**
255
255
``` v ignore
@@ -270,7 +270,7 @@ on the url http://localhost:port/normal we will not see `from normal`, but
270
270
271
271
### Custom not found page
272
272
273
- You can implement a ` not_found ` endpoint that is called when a request is made and no
273
+ You can implement a ` not_found ` endpoint that is called when a request is made, and no
274
274
matching route is found to replace the default HTTP 404 not found page. This route
275
275
has to be defined on our Context struct.
276
276
@@ -286,7 +286,7 @@ pub fn (mut ctx Context) not_found() vweb.Result {
286
286
287
287
## Static files and website
288
288
289
- Vweb also provides a way of handling static files. We can mount a folder at the root
289
+ vweb also provides a way of handling static files. We can mount a folder at the root
290
290
of our web app, or at a custom route. To start using static files we have to embed
291
291
` vweb.StaticHandler ` on our app struct.
292
292
@@ -303,7 +303,7 @@ Let's say you have the following file structure:
303
303
└── main.v
304
304
```
305
305
306
- If we want all the documents inside the ` static ` sub-directory to be publicly accessible we can
306
+ If we want all the documents inside the ` static ` sub-directory to be publicly accessible, we can
307
307
use ` handle_static ` .
308
308
309
309
> ** Note:**
@@ -352,7 +352,7 @@ We can now access `main.css` directly at http://localhost:8080/css/main.css.
352
352
If a request is made to the root of a static folder, vweb will look for an
353
353
` index.html ` or ` ìndex.htm ` file and serve it if available.
354
354
Thus, it's also a good way to host a complete website.
355
- A example is available [ here] ( /examples/vweb/static_website ) .
355
+ An example is available [ here] ( /examples/vweb/static_website ) .
356
356
357
357
It is also possible to mount the ` static ` folder at a custom path.
358
358
@@ -376,7 +376,7 @@ app.serve_static('/path/main.css', 'static/css/main.css')!
376
376
377
377
### Dealing with MIME types
378
378
379
- By default vweb will map the extension of a file to a MIME type. If any of your static file's
379
+ By default, vweb will map the extension of a file to a MIME type. If any of your static file's
380
380
extensions do not have a default MIME type in vweb, vweb will throw an error and you
381
381
have to add your MIME type to ` .static_mime_types ` yourself.
382
382
@@ -505,7 +505,7 @@ app.route_use('/user/:path...')
505
505
506
506
### Evaluation moment
507
507
508
- By default the registered middleware functions are executed * before* a method on your
508
+ By default, the registered middleware functions are executed * before* a method on your
509
509
app struct is called. You can also change this behaviour to execute middleware functions
510
510
* after* a method on your app struct is called, but before the response is sent!
511
511
@@ -530,7 +530,7 @@ Anything you can do in "before" middleware, you can do in "after" middleware.
530
530
531
531
### Evaluation order
532
532
533
- Vweb will handle requests in the following order:
533
+ vweb will handle requests in the following order:
534
534
535
535
1 . Execute global "before" middleware
536
536
2 . Execute "before" middleware that matches the requested route
@@ -574,7 +574,7 @@ for urls starting with `'/foo'`.
574
574
575
575
To use controllers we have to embed ` vweb.Controller ` on
576
576
our app struct and when we register a controller we also have to specify
577
- what the type of the context struct will be. That means that is is possible
577
+ what the type of the context struct will be. That means that it is possible
578
578
to have a different context struct for each controller and the main app struct.
579
579
580
580
** Example:**
@@ -642,7 +642,7 @@ When we registered the controller with
642
642
we told vweb that the namespace of that controller is ` '/admin' ` so in this example we would
643
643
see the text "Admin" if we navigate to the url ` '/admin/path' ` .
644
644
645
- Vweb doesn't support duplicate routes, so if we add the following
645
+ vweb doesn't support duplicate routes, so if we add the following
646
646
route to the example the code will produce an error.
647
647
648
648
``` v ignore
@@ -778,7 +778,7 @@ You must pass the type of redirect to vweb:
778
778
779
779
If you want to change the request method, for example when you receive a post request and
780
780
want to redirect to another page via a GET request, you should use ` see_other ` . If you want
781
- the HTTP method to stay the same you should use ` found ` generally speaking.
781
+ the HTTP method to stay the same, you should use ` found ` generally speaking.
782
782
783
783
** Example:**
784
784
``` v ignore
@@ -825,7 +825,7 @@ sending a response over the connection and closing it.
825
825
Sometimes you want to send the response in another thread, for example when using
826
826
[ Server Sent Events] ( sse/README.md ) . When you are sure that a response will be sent
827
827
over the TCP connection you can return ` vweb.no_result() ` . This function does nothing
828
- and returns an empty ` vweb.Result ` struct, letting vweb know that we sent a response ourself .
828
+ and returns an empty ` vweb.Result ` struct, letting vweb know that we sent a response ourselves .
829
829
830
830
> ** Note:**
831
831
> It is important to call ` ctx.takeover_conn ` before you spawn a thread
@@ -856,7 +856,7 @@ pub fn (app &App) long_response(mut ctx Context) vweb.Result {
856
856
// if we don't the whole web server will block for 10 seconds,
857
857
// since vweb is singlethreaded
858
858
spawn handle_connection(mut ctx.conn)
859
- // we will send a custom response ourself , so we can safely return an empty result
859
+ // we will send a custom response ourselves , so we can safely return an empty result
860
860
return vweb.no_result()
861
861
}
862
862
0 commit comments