Skip to content

Commit ee1305c

Browse files
authored
Update README.md
1 parent adb9b37 commit ee1305c

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,23 @@ await server.appendRoute(for: "GET /fish/*", to: routes)
120120
Routes allow requests to be identified by `HTTPMethod` and path and can be [pattern matched](https://docs.swift.org/swift-book/ReferenceManual/Patterns.html#ID426) against requests:
121121

122122
```swift
123-
let HTTPRoute("/hello/world")
123+
let route = HTTPRoute("/hello/world")
124124

125125
route ~= HTTPRequest(method: .GET, path: "/hello/world") // true
126126
route ~= HTTPRequest(method: .POST, path: "/hello/world") // true
127127
route ~= HTTPRequest(method: .GET, path: "/hello/") // false
128128
```
129129

130+
Routes are `ExpressibleByStringLiteral`, so literals will be automatically converted to `HTTPRoute`:
131+
132+
```swift
133+
let route: HTTPRoute = "/hello/world"
134+
```
135+
130136
Routes can include specific methods to match against:
131137

132138
```swift
133-
let HTTPRoute("GET /hello/world")
139+
let route = HTTPRoute("GET /hello/world")
134140

135141
route ~= HTTPRequest(method: .GET, path: "/hello/world") // true
136142
route ~= HTTPRequest(method: .POST, path: "/hello/world") // false
@@ -139,7 +145,7 @@ route ~= HTTPRequest(method: .POST, path: "/hello/world") // false
139145
And can use wildcards within the path
140146

141147
```swift
142-
let HTTPRoute("GET /hello/*/world")
148+
let route = HTTPRoute("GET /hello/*/world")
143149

144150
route ~= HTTPRequest(method: .GET, path: "/hello/fish/world") // true
145151
route ~= HTTPRequest(method: .POST, path: "/hello/dog/world") // true
@@ -149,7 +155,7 @@ route ~= HTTPRequest(method: .POST, path: "/hello/fish/sea") // false
149155
Trailing wildcards match all trailing path components:
150156

151157
```swift
152-
let HTTPRoute("GET /hello/*")
158+
let route = HTTPRoute("GET /hello/*")
153159

154160
route ~= HTTPRequest(method: .GET, path: "/hello/fish/world") // true
155161
route ~= HTTPRequest(method: .POST, path: "/hello/dog/world") // true

0 commit comments

Comments
 (0)