diff --git a/3.0/docs/routing/parameters.md b/3.0/docs/routing/parameters.md index e69de29b..7fdef721 100644 --- a/3.0/docs/routing/parameters.md +++ b/3.0/docs/routing/parameters.md @@ -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!!! diff --git a/3.0/docs/routing/route.md b/3.0/docs/routing/route.md index e69de29b..24f1af22 100644 --- a/3.0/docs/routing/route.md +++ b/3.0/docs/routing/route.md @@ -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. diff --git a/3.0/docs/vapor/route-collection.md b/3.0/docs/vapor/route-collection.md new file mode 100644 index 00000000..d9ccf7fa --- /dev/null +++ b/3.0/docs/vapor/route-collection.md @@ -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) { + ... + } +} +``` diff --git a/3.0/docs/vapor/collection.md b/3.0/docs/web/multipart.md similarity index 100% rename from 3.0/docs/vapor/collection.md rename to 3.0/docs/web/multipart.md diff --git a/3.0/mkdocs.yml b/3.0/mkdocs.yml index 05a90788..b656f664 100644 --- a/3.0/mkdocs.yml +++ b/3.0/mkdocs.yml @@ -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'