Skip to content

Commit 01e4421

Browse files
authored
Small cleanup (#501)
* Add path segment wildcard test to testrunner * Fix compiler warning about class keyword * Fix (some) linter warnings
1 parent d998bf5 commit 01e4421

File tree

6 files changed

+7
-5
lines changed

6 files changed

+7
-5
lines changed

Xcode/Sources/HttpServer.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ open class HttpServer: HttpServerIO {
4242
public var delete, patch, head, post, get, put: MethodRoute
4343

4444
public subscript(path: String) -> ((HttpRequest) -> HttpResponse)? {
45+
get { return nil }
4546
set {
4647
router.register(nil, path: path, handler: newValue)
4748
}
48-
get { return nil }
4949
}
5050

5151
public var routes: [String] {
@@ -75,10 +75,10 @@ open class HttpServer: HttpServerIO {
7575
public let method: String
7676
public let router: HttpRouter
7777
public subscript(path: String) -> ((HttpRequest) -> HttpResponse)? {
78+
get { return nil }
7879
set {
7980
router.register(method, path: path, handler: newValue)
8081
}
81-
get { return nil }
8282
}
8383
}
8484
}

Xcode/Sources/HttpServerIO.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import Foundation
99
import Dispatch
1010

11-
public protocol HttpServerIODelegate: class {
11+
public protocol HttpServerIODelegate: AnyObject {
1212
func socketConnectionReceived(_ socket: Socket)
1313
}
1414

Xcode/Sources/WebSockets.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ public class WebSocketSession: Hashable, Equatable {
277277
}
278278

279279
let mask = [try socket.read(), try socket.read(), try socket.read(), try socket.read()]
280-
//Read payload all at once, then apply mask (calling `socket.read` byte-by-byte is super slow).
280+
// Read payload all at once, then apply mask (calling `socket.read` byte-by-byte is super slow).
281281
frm.payload = try socket.read(length: Int(len))
282282
for index in 0..<len {
283283
frm.payload[Int(index)] ^= mask[Int(index % 4)]

Xcode/SwifterSampleOSX/main.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import Swifter
1010
do {
1111
let server = demoServer(try String.File.currentWorkingDirectory())
1212
server["/testAfterBaseRoute"] = { request in
13+
print("Received request: \(request)")
1314
return .ok(.htmlBody("ok !"))
1415
}
1516

Xcode/Tests/PingServer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import FoundationNetworking
1616
extension HttpServer {
1717
class func pingServer() -> HttpServer {
1818
let server = HttpServer()
19-
server.GET["/ping"] = { request in
19+
server.GET["/ping"] = { _ in
2020
return HttpResponse.ok(.text("pong!"))
2121
}
2222
return server

Xcode/Tests/XCTestManifests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ extension SwifterTestsHttpRouter {
6363
("testHttpRouterHandlesOverlappingPathsInDynamicRoutes", testHttpRouterHandlesOverlappingPathsInDynamicRoutes),
6464
("testHttpRouterHandlesOverlappingPathsInDynamicRoutesInTheMiddle", testHttpRouterHandlesOverlappingPathsInDynamicRoutesInTheMiddle),
6565
("testHttpRouterMultiplePathSegmentWildcards", testHttpRouterMultiplePathSegmentWildcards),
66+
("testHttpRouterMultiplePathSegmentWildcardTail", testHttpRouterMultiplePathSegmentWildcardTail),
6667
("testHttpRouterPercentEncodedPathSegments", testHttpRouterPercentEncodedPathSegments),
6768
("testHttpRouterShouldHandleOverlappingRoutesInTrail", testHttpRouterShouldHandleOverlappingRoutesInTrail),
6869
("testHttpRouterSimplePathSegments", testHttpRouterSimplePathSegments),

0 commit comments

Comments
 (0)