fixed routing tests

This commit is contained in:
Joannis Orlandos 2017-09-10 13:59:27 +02:00
parent 38d9b3a570
commit 56c7125d37
5 changed files with 52 additions and 2 deletions

View File

@ -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!!!

View File

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

View File

@ -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) {
...
}
}
```

View File

@ -19,6 +19,7 @@ pages:
- 'Headers': 'web/headers.md'
- 'Method': 'http/method.md'
- 'Middleware': 'http/middleware.md'
- 'Multipart': 'web/multipart.md'
- 'Response': 'http/response.md'
- 'Responder': 'http/responder.md'
- 'Request': 'http/request.md'
@ -35,7 +36,6 @@ pages:
# - MySQL:
- Routing:
- 'Async': 'routing/async.md'
- 'Route Collection': 'routing/collection.md'
- 'Parameters': 'routing/parameters.md'
- 'Route': 'routing/route.md'
- 'Router': 'routing/router.md'
@ -45,7 +45,7 @@ pages:
# - ''
# - TLS:
# - Vapor:
# - 'Route Group': 'routing/group.md'
# - 'Route Collection': 'vapor/route-collection.md'
- WebSocket:
- 'Basics':
- 'Binary': 'websocket/binary-stream.md'