mirror of https://github.com/vapor/docs.git
fixed routing tests
This commit is contained in:
parent
38d9b3a570
commit
56c7125d37
|
|
@ -0,0 +1,24 @@
|
||||||
|
# Parameters
|
||||||
|
|
||||||
|
Parameters are a registered type that can be initialized from a String.
|
||||||
|
|
||||||
|
They can be part of a [Route](route.md), and be extracted from [Requests](../http/request.md) that are called in that Route.
|
||||||
|
|
||||||
|
## Creating custom parameters
|
||||||
|
|
||||||
|
To create a custom parameter type, simply conform to `Parameter` and implement the conversion function `make` and a unique slug.
|
||||||
|
|
||||||
|
In this example, the `User` class will be initialized from a parameter that represents it's identifier.
|
||||||
|
|
||||||
|
```swift
|
||||||
|
class User : Parameter {
|
||||||
|
static var uniqueSlug = "my-app:user"
|
||||||
|
|
||||||
|
static func make(for parameter: String, in request: Request) throws -> User {
|
||||||
|
// Fetches the user from MySQL
|
||||||
|
let user =
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
TODO!!!
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
# Route
|
||||||
|
|
||||||
|
Route is an object that contains the essential information of an HTTP Route.
|
||||||
|
|
||||||
|
It contains the route's Method, path components and responder.
|
||||||
|
|
||||||
|
## Extensions
|
||||||
|
|
||||||
|
Route is [`Extendable`](../core/extend.md), meaning you can extend it's properties.
|
||||||
|
|
||||||
|
The purpose is to allow documentation tools to hook into the Vapor routing process.
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
# Route Collection
|
||||||
|
|
||||||
|
`RouteCollection` is a protocol that you can conform your controllers to.
|
||||||
|
|
||||||
|
They require the implementation of the `register` function which can then register the routes to a router.
|
||||||
|
|
||||||
|
```swift
|
||||||
|
class LoginController {
|
||||||
|
init() {}
|
||||||
|
|
||||||
|
func register(to router: Router) {
|
||||||
|
...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
@ -19,6 +19,7 @@ pages:
|
||||||
- 'Headers': 'web/headers.md'
|
- 'Headers': 'web/headers.md'
|
||||||
- 'Method': 'http/method.md'
|
- 'Method': 'http/method.md'
|
||||||
- 'Middleware': 'http/middleware.md'
|
- 'Middleware': 'http/middleware.md'
|
||||||
|
- 'Multipart': 'web/multipart.md'
|
||||||
- 'Response': 'http/response.md'
|
- 'Response': 'http/response.md'
|
||||||
- 'Responder': 'http/responder.md'
|
- 'Responder': 'http/responder.md'
|
||||||
- 'Request': 'http/request.md'
|
- 'Request': 'http/request.md'
|
||||||
|
|
@ -35,7 +36,6 @@ pages:
|
||||||
# - MySQL:
|
# - MySQL:
|
||||||
- Routing:
|
- Routing:
|
||||||
- 'Async': 'routing/async.md'
|
- 'Async': 'routing/async.md'
|
||||||
- 'Route Collection': 'routing/collection.md'
|
|
||||||
- 'Parameters': 'routing/parameters.md'
|
- 'Parameters': 'routing/parameters.md'
|
||||||
- 'Route': 'routing/route.md'
|
- 'Route': 'routing/route.md'
|
||||||
- 'Router': 'routing/router.md'
|
- 'Router': 'routing/router.md'
|
||||||
|
|
@ -45,7 +45,7 @@ pages:
|
||||||
# - ''
|
# - ''
|
||||||
# - TLS:
|
# - TLS:
|
||||||
# - Vapor:
|
# - Vapor:
|
||||||
# - 'Route Group': 'routing/group.md'
|
# - 'Route Collection': 'vapor/route-collection.md'
|
||||||
- WebSocket:
|
- WebSocket:
|
||||||
- 'Basics':
|
- 'Basics':
|
||||||
- 'Binary': 'websocket/binary-stream.md'
|
- 'Binary': 'websocket/binary-stream.md'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue