Skip to content

Commit 66291cb

Browse files
committed
Docs
...
1 parent 37d6758 commit 66291cb

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

Sources/express/Route.swift

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Noze.io / Macro
44
//
55
// Created by Helge Heß on 6/2/16.
6-
// Copyright © 2016-2020 ZeeZide GmbH. All rights reserved.
6+
// Copyright © 2016-2025 ZeeZide GmbH. All rights reserved.
77
//
88

99
import enum NIOHTTP1.HTTPMethod
@@ -21,10 +21,11 @@ private let debugMatcher = process.getenvflag("macro.router.matcher.debug")
2121
private let debugWalker = process.getenvflag("macro.router.walker.debug")
2222

2323
/**
24-
* A Route is a middleware which wraps another middleware and guards it by a
24+
* A ``Route`` is a middleware which wraps another middleware and guards it by a
2525
* condition. For example:
26-
*
27-
* app.get("/index") { req, res, next in ... }
26+
* ```swift
27+
* app.get("/index") { req, res, next in ... }
28+
* ```
2829
*
2930
* This creates a Route wrapping the closure given. It only runs the
3031
* embedded closure if:
@@ -45,8 +46,14 @@ private let debugWalker = process.getenvflag("macro.router.walker.debug")
4546
* - otherwise the text is matched AS IS
4647
*
4748
* Variables can be extracted using:
48-
*
49-
* req.params[int: "id"]
49+
* ```swift
50+
* app.get("/user/:id/view") { req, res in
51+
* guard let id = req.params[int: "id"] else {
52+
* return res.sendStatus(404) // TBD: or 400?
53+
* }
54+
* ...
55+
* }
56+
* ```
5057
*
5158
* and companions.
5259
*/

0 commit comments

Comments
 (0)