Skip to content

Commit 685855f

Browse files
committed
added default value for custom headers
1 parent 8ee4eb8 commit 685855f

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

Xcode/Sources/HttpResponse.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public enum HttpResponseBody {
8080
public enum HttpResponse {
8181

8282
case switchProtocols([String: String], (Socket) -> Void)
83-
case ok(HttpResponseBody, [String: String]), created, accepted
83+
case ok(HttpResponseBody, [String: String] = [:]), created, accepted
8484
case movedPermanently(String)
8585
case movedTemporarily(String)
8686
case badRequest(HttpResponseBody?), unauthorized, forbidden, notFound, notAcceptable

Xcode/Tests/PingServer.swift

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

Xcode/Tests/ServerThreadingTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class ServerThreadingTests: XCTestCase {
3535
let queue = DispatchQueue(label: "com.swifter.threading")
3636
let hostURL: URL
3737

38-
server.GET[path] = { .ok(.htmlBody("You asked for " + $0.path), [:]) }
38+
server.GET[path] = { .ok(.htmlBody("You asked for " + $0.path)) }
3939

4040
do {
4141

@@ -73,7 +73,7 @@ class ServerThreadingTests: XCTestCase {
7373
func testShouldHandleTheSameRequestConcurrently() {
7474

7575
let path = "/a/:b/c"
76-
server.GET[path] = { .ok(.htmlBody("You asked for " + $0.path), [:]) }
76+
server.GET[path] = { .ok(.htmlBody("You asked for " + $0.path)) }
7777

7878
var requestExpectation: XCTestExpectation? = expectation(description: "Should handle the request concurrently")
7979

Xcode/Tests/SwifterTestsHttpRouter.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class SwifterTestsHttpRouter: XCTestCase {
2626
func testHttpRouterSlashRoot() {
2727

2828
router.register(nil, path: "/", handler: { _ in
29-
return .ok(.htmlBody("OK"), [:])
29+
return .ok(.htmlBody("OK"))
3030
})
3131

3232
XCTAssertNotNil(router.route(nil, path: "/"))
@@ -35,7 +35,7 @@ class SwifterTestsHttpRouter: XCTestCase {
3535
func testHttpRouterSimplePathSegments() {
3636

3737
router.register(nil, path: "/a/b/c/d", handler: { _ in
38-
return .ok(.htmlBody("OK"), [:])
38+
return .ok(.htmlBody("OK"))
3939
})
4040

4141
XCTAssertNil(router.route(nil, path: "/"))
@@ -48,7 +48,7 @@ class SwifterTestsHttpRouter: XCTestCase {
4848
func testHttpRouterSinglePathSegmentWildcard() {
4949

5050
router.register(nil, path: "/a/*/c/d", handler: { _ in
51-
return .ok(.htmlBody("OK"), [:])
51+
return .ok(.htmlBody("OK"))
5252
})
5353

5454
XCTAssertNil(router.route(nil, path: "/"))
@@ -62,7 +62,7 @@ class SwifterTestsHttpRouter: XCTestCase {
6262
func testHttpRouterVariables() {
6363

6464
router.register(nil, path: "/a/:arg1/:arg2/b/c/d/:arg3", handler: { _ in
65-
return .ok(.htmlBody("OK"), [:])
65+
return .ok(.htmlBody("OK"))
6666
})
6767

6868
XCTAssertNil(router.route(nil, path: "/"))
@@ -76,7 +76,7 @@ class SwifterTestsHttpRouter: XCTestCase {
7676
func testHttpRouterMultiplePathSegmentWildcards() {
7777

7878
router.register(nil, path: "/a/**/e/f/g", handler: { _ in
79-
return .ok(.htmlBody("OK"), [:])
79+
return .ok(.htmlBody("OK"))
8080
})
8181

8282
XCTAssertNil(router.route(nil, path: "/"))
@@ -88,7 +88,7 @@ class SwifterTestsHttpRouter: XCTestCase {
8888
func testHttpRouterMultiplePathSegmentWildcardTail() {
8989

9090
router.register(nil, path: "/a/b/**", handler: { _ in
91-
return .ok(.htmlBody("OK"), [:])
91+
return .ok(.htmlBody("OK"))
9292
})
9393

9494
XCTAssertNil(router.route(nil, path: "/"))
@@ -100,11 +100,11 @@ class SwifterTestsHttpRouter: XCTestCase {
100100
func testHttpRouterEmptyTail() {
101101

102102
router.register(nil, path: "/a/b/", handler: { _ in
103-
return .ok(.htmlBody("OK"), [:])
103+
return .ok(.htmlBody("OK"))
104104
})
105105

106106
router.register(nil, path: "/a/b/:var", handler: { _ in
107-
return .ok(.htmlBody("OK"), [:])
107+
return .ok(.htmlBody("OK"))
108108
})
109109

110110
XCTAssertNil(router.route(nil, path: "/"))
@@ -120,7 +120,7 @@ class SwifterTestsHttpRouter: XCTestCase {
120120
func testHttpRouterPercentEncodedPathSegments() {
121121

122122
router.register(nil, path: "/a/<>/^", handler: { _ in
123-
return .ok(.htmlBody("OK"), [:])
123+
return .ok(.htmlBody("OK"))
124124
})
125125

126126
XCTAssertNil(router.route(nil, path: "/"))

0 commit comments

Comments
 (0)