update manifest format

This commit is contained in:
tanner0101 2019-10-24 16:50:35 -04:00
parent ef922fe086
commit 9f1282b71f
2 changed files with 23 additions and 4 deletions

View File

@ -1,6 +1,6 @@
# Routes
A route specifies a request handler for a given HTTP method and URI path. They can also store additional metadata.
A route specifies a request handler for a given HTTP method and URI path. It can also store additional metadata.
## Methods
@ -77,6 +77,15 @@ app.get("foo", ":bar", "baz") { req in
This is very similar to parameter except the value is discarded. This path component is specified as just `:`.
```swift
// responds to GET /foo/bar/baz
// responds to GET /foo/qux/baz
// ...
app.get("foo", ":", "baz") { req in
...
}
```
### Catchall
This is a dynamic route component that matches one or more components. It is specified using just `*`. Any string at this position or later positions will be allowed in the request.
@ -92,7 +101,7 @@ app.get("foo", "*") { req in
## Parameters
When using a parameter path component (prefixed with `:`), the value of the URI at that location will be stored in `req.parameters`. You can use the name of the path component to access the value.
When using a parameter path component (prefixed with `:`), the value of the URI at that position will be stored in `req.parameters`. You can use the name of the path component to access the value.
```swift
// responds to GET /hello/foo
@ -162,4 +171,14 @@ $ swift run Run routes
+--------+----------------+
| DELETE | /todos/:todoID |
+--------+----------------+
```
## Metadata
All route registration methods return the created `Route`. This allows you to metadata to the route's `userInfo` dictionary. There are some default methods available, like adding a description.
```swift
app.get("hello", ":name") { req in
...
}.description("says hello")
```

View File

@ -34,8 +34,8 @@ nav:
- 'Folder Structure': 'getting-started/folder-structure.md'
- 'SPM': 'getting-started/spm.md'
- 'Routing':
'Overview': 'routing/overview.md'
'Routes': 'routing/routes.md'
- 'Overview': 'routing/overview.md'
- 'Routes': 'routing/routes.md'
- 'Version (4.0)':
- '1.5': 'version/1_5.md'
- '2.0': 'version/2_0.md'