Skip to content

Commit 0073283

Browse files
authored
vweb: add parameter arrays documentation (#18903)
1 parent a794dea commit 0073283

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

vlib/vweb/README.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,23 @@ header you want example. `app.req.header.get(.content_type)`. See `struct Header
234234
for all available methods (`v doc net.http Header`).
235235
It has, too, fields for the `query`, `form`, `files`.
236236

237+
#### - Parameter Arrays
238+
239+
If you want multiple parameters in your route and if you want to parse the parameters
240+
yourself, or you want a wildcard route, you can add `...` after the `:` and name,
241+
e.g. `['/:path...']`.
242+
243+
This will match all routes after `'/'`. For example the url `/path/to/test` would give
244+
`path = '/path/to/test'`.
245+
246+
```v ignore
247+
vvv
248+
['/:path...'] vvvv
249+
fn (mut app App) wildcard(path string) vweb.Result {
250+
return app.text('URL path = "${path}"')
251+
}
252+
```
253+
237254
#### - Query
238255
To handle the query context, you just need use the `query` field
239256

@@ -500,9 +517,9 @@ pub fn (mut app App) with_auth() bool {
500517
}
501518
```
502519

503-
### Fallback route
504-
You can implement a fallback `not_found` route that is called when a request is made and no
505-
matching route is found.
520+
### Custom not found page
521+
You can implement a `not_found` route that is called when a request is made and no
522+
matching route is found to replace the default HTTP 404 not found page.
506523

507524
**Example:**
508525

0 commit comments

Comments
 (0)