Skip to content

Commit

Permalink
Bridge KituraNet.HTTPStatusCode (#1217)
Browse files Browse the repository at this point in the history
  • Loading branch information
tunniclm authored and djones6 committed Mar 16, 2018
1 parent 62d2183 commit 6690f2b
Show file tree
Hide file tree
Showing 66 changed files with 2,127 additions and 70 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ matrix:
- os: osx
osx_image: xcode9.2
sudo: required
env: JAZZY_ELIGIBLE=true
- os: linux
dist: trusty
sudo: required
Expand Down
25 changes: 25 additions & 0 deletions Sources/Kitura/HTTPStatusCode.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright IBM Corporation 2018
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import KituraNet

/// A dummy class to get the documentation for the HTTPStatusCode below to be emitted.
private class DummyHTTPStatusCodeClass {}

/// Bridge [HTTPStatusCode](http://ibm-swift.github.io/Kitura-net/Enums/HTTPStatusCode.html)
/// from [KituraNet](http://ibm-swift.github.io/Kitura-net) so that you only need to import
/// `Kitura` to access it.
public typealias HTTPStatusCode = KituraNet.HTTPStatusCode
74 changes: 74 additions & 0 deletions Tests/KituraTests/TestBridgingHTTPStatusCode.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/**
* Copyright IBM Corporation 2016, 2018
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/

import XCTest
import Foundation

@testable import Kitura

#if os(Linux)
import Glibc
#else
import Darwin
#endif

// This file does not import KituraNet and is relying on the typealias of
// HTTPStatusCode. This test is a simple response test to check that referring
// to HTTPStatusCode builds and runs without error. Other existing tests
// that import KituraNet should be sufficient to show that the typealias does not
// interfere in that case.
class TestBridgingHTTPStatusCode: KituraTest {

static var allTests: [(String, (TestBridgingHTTPStatusCode) -> () throws -> Void)] {
return [
("testSimpleResponse", testSimpleResponse)
]
}

let router = TestBridgingHTTPStatusCode.setupRouter()

func testSimpleResponse() {
performServerTest(router) { expectation in
self.performRequest("get", path:"/qwer", callback: {response in
XCTAssertNotNil(response, "ERROR!!! ClientRequest response object was nil")
XCTAssertEqual(response?.statusCode, HTTPStatusCode.OK, "HTTP Status code was \(String(describing: response?.statusCode))")
XCTAssertNotNil(response?.headers["Date"], "There was No Date header in the response")
//XCTAssertEqual(response?.method, "GET", "The request wasn't recognized as a get")
do {
let body = try response?.readString()
XCTAssertEqual(body, "<!DOCTYPE html><html><body><b>Received</b></body></html>\n\n")
} catch {
XCTFail("Error reading body")
}
expectation.fulfill()
})
}
}

static func setupRouter() -> Router {
let router = Router()
router.get("/qwer") { _, response, next in
response.headers["Content-Type"] = "text/html; charset=utf-8"
do {
try response.send("<!DOCTYPE html><html><body><b>Received</b></body></html>\n\n").end()
} catch {
XCTFail("Error sending response. Error=\(error.localizedDescription)")
}
next()
}
return router
}
}
8 changes: 7 additions & 1 deletion docs/Classes.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@
<li class="nav-group-name">
<a class="nav-group-name-link" href="Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/CodableHelpers.html">CodableHelpers</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/HTTPVersion.html">HTTPVersion</a>
</li>
Expand All @@ -138,6 +141,9 @@
<li class="nav-group-name">
<a class="nav-group-name-link" href="Typealiases.html">Type Aliases</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="Typealiases.html#/s:6Kitura14HTTPStatusCodea">HTTPStatusCode</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Typealiases.html#/s:6Kitura16LifecycleHandlera">LifecycleHandler</a>
</li>
Expand Down Expand Up @@ -559,7 +565,7 @@ <h4>Declaration</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2018 <a class="link" href="" target="_blank" rel="external">IBM</a>. All rights reserved. (Last updated: 2018-02-28)</p>
<p>&copy; 2018 <a class="link" href="" target="_blank" rel="external">IBM</a>. All rights reserved. (Last updated: 2018-03-16)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.1</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
Expand Down
8 changes: 7 additions & 1 deletion docs/Classes/BodyParser.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/CodableHelpers.html">CodableHelpers</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/HTTPVersion.html">HTTPVersion</a>
</li>
Expand All @@ -139,6 +142,9 @@
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Typealiases.html">Type Aliases</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Typealiases.html#/s:6Kitura14HTTPStatusCodea">HTTPStatusCode</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Typealiases.html#/s:6Kitura16LifecycleHandlera">LifecycleHandler</a>
</li>
Expand Down Expand Up @@ -422,7 +428,7 @@ <h4>Return Value</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2018 <a class="link" href="" target="_blank" rel="external">IBM</a>. All rights reserved. (Last updated: 2018-02-28)</p>
<p>&copy; 2018 <a class="link" href="" target="_blank" rel="external">IBM</a>. All rights reserved. (Last updated: 2018-03-16)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.1</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
Expand Down
8 changes: 7 additions & 1 deletion docs/Classes/ContentType.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/CodableHelpers.html">CodableHelpers</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/HTTPVersion.html">HTTPVersion</a>
</li>
Expand All @@ -139,6 +142,9 @@
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Typealiases.html">Type Aliases</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Typealiases.html#/s:6Kitura14HTTPStatusCodea">HTTPStatusCode</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Typealiases.html#/s:6Kitura16LifecycleHandlera">LifecycleHandler</a>
</li>
Expand Down Expand Up @@ -398,7 +404,7 @@ <h4>Return Value</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2018 <a class="link" href="" target="_blank" rel="external">IBM</a>. All rights reserved. (Last updated: 2018-02-28)</p>
<p>&copy; 2018 <a class="link" href="" target="_blank" rel="external">IBM</a>. All rights reserved. (Last updated: 2018-03-16)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.1</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
Expand Down
8 changes: 7 additions & 1 deletion docs/Classes/Kitura.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/CodableHelpers.html">CodableHelpers</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/HTTPVersion.html">HTTPVersion</a>
</li>
Expand All @@ -139,6 +142,9 @@
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Typealiases.html">Type Aliases</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Typealiases.html#/s:6Kitura14HTTPStatusCodea">HTTPStatusCode</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Typealiases.html#/s:6Kitura16LifecycleHandlera">LifecycleHandler</a>
</li>
Expand Down Expand Up @@ -504,7 +510,7 @@ <h4>Parameters</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2018 <a class="link" href="" target="_blank" rel="external">IBM</a>. All rights reserved. (Last updated: 2018-02-28)</p>
<p>&copy; 2018 <a class="link" href="" target="_blank" rel="external">IBM</a>. All rights reserved. (Last updated: 2018-03-16)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.1</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
Expand Down
8 changes: 7 additions & 1 deletion docs/Classes/RouteRegex.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/CodableHelpers.html">CodableHelpers</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/HTTPVersion.html">HTTPVersion</a>
</li>
Expand All @@ -139,6 +142,9 @@
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Typealiases.html">Type Aliases</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Typealiases.html#/s:6Kitura14HTTPStatusCodea">HTTPStatusCode</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Typealiases.html#/s:6Kitura16LifecycleHandlera">LifecycleHandler</a>
</li>
Expand Down Expand Up @@ -210,7 +216,7 @@ <h4>Declaration</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2018 <a class="link" href="" target="_blank" rel="external">IBM</a>. All rights reserved. (Last updated: 2018-02-28)</p>
<p>&copy; 2018 <a class="link" href="" target="_blank" rel="external">IBM</a>. All rights reserved. (Last updated: 2018-03-16)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.1</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
Expand Down
8 changes: 7 additions & 1 deletion docs/Classes/Router.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/CodableHelpers.html">CodableHelpers</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/HTTPVersion.html">HTTPVersion</a>
</li>
Expand All @@ -139,6 +142,9 @@
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Typealiases.html">Type Aliases</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Typealiases.html#/s:6Kitura14HTTPStatusCodea">HTTPStatusCode</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Typealiases.html#/s:6Kitura16LifecycleHandlera">LifecycleHandler</a>
</li>
Expand Down Expand Up @@ -9612,7 +9618,7 @@ <h4>Parameters</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2018 <a class="link" href="" target="_blank" rel="external">IBM</a>. All rights reserved. (Last updated: 2018-02-28)</p>
<p>&copy; 2018 <a class="link" href="" target="_blank" rel="external">IBM</a>. All rights reserved. (Last updated: 2018-03-16)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.1</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
Expand Down
8 changes: 7 additions & 1 deletion docs/Classes/RouterMiddlewareGenerator.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/CodableHelpers.html">CodableHelpers</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/HTTPVersion.html">HTTPVersion</a>
</li>
Expand All @@ -139,6 +142,9 @@
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Typealiases.html">Type Aliases</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Typealiases.html#/s:6Kitura14HTTPStatusCodea">HTTPStatusCode</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Typealiases.html#/s:6Kitura16LifecycleHandlera">LifecycleHandler</a>
</li>
Expand Down Expand Up @@ -304,7 +310,7 @@ <h4>Parameters</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2018 <a class="link" href="" target="_blank" rel="external">IBM</a>. All rights reserved. (Last updated: 2018-02-28)</p>
<p>&copy; 2018 <a class="link" href="" target="_blank" rel="external">IBM</a>. All rights reserved. (Last updated: 2018-03-16)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.1</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
Expand Down
8 changes: 7 additions & 1 deletion docs/Classes/RouterRequest.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/CodableHelpers.html">CodableHelpers</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/HTTPVersion.html">HTTPVersion</a>
</li>
Expand All @@ -139,6 +142,9 @@
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Typealiases.html">Type Aliases</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Typealiases.html#/s:6Kitura14HTTPStatusCodea">HTTPStatusCode</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Typealiases.html#/s:6Kitura16LifecycleHandlera">LifecycleHandler</a>
</li>
Expand Down Expand Up @@ -1071,7 +1077,7 @@ <h4>Return Value</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2018 <a class="link" href="" target="_blank" rel="external">IBM</a>. All rights reserved. (Last updated: 2018-02-28)</p>
<p>&copy; 2018 <a class="link" href="" target="_blank" rel="external">IBM</a>. All rights reserved. (Last updated: 2018-03-16)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.1</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
Expand Down

0 comments on commit 6690f2b

Please sign in to comment.