-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Matteo
committed
Aug 21, 2016
0 parents
commit 729af4d
Showing
6 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.build | ||
.vagrant | ||
Packages | ||
*.pkg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DEVELOPMENT-SNAPSHOT-2016-07-25-a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "ToriAllowRemoteOrigin", | ||
dependencies: [ | ||
.Package(url: "https://github.com/IBM-Swift/Kitura.git", majorVersion: 0, minor: 26) | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* Copyright boostco.de 2016 | ||
* | ||
* 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 Foundation | ||
|
||
import Kitura | ||
|
||
private typealias AllowRemoteMiddlware = RouterMiddleware | ||
class AllowRemoteOrigin: AllowRemoteMiddlware { | ||
func handle(request: RouterRequest, response: RouterResponse, next: () -> Void) { | ||
|
||
// enable cors | ||
response.headers.append("Access-Control-Allow-Origin", value: "*") | ||
// set response to be only json formatted | ||
response.headers.append("Content-Type", value: "application/json; charset=utf-8") | ||
next() | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import XCTest | ||
@testable import ToriAllowRemoteOriginTestSuite | ||
|
||
XCTMain([ | ||
testCase(ToriAllowRemoteOriginTests.allTests), | ||
]) |
17 changes: 17 additions & 0 deletions
17
Tests/ToriAllowRemoteOrigin/ToriAllowRemoteOriginTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import XCTest | ||
@testable import ToriAllowRemoteOrigin | ||
|
||
class ToriAllowRemoteOriginTests: XCTestCase { | ||
func testExample() { | ||
// This is an example of a functional test case. | ||
// Use XCTAssert and related functions to verify your tests produce the correct results. | ||
XCTAssertEqual(ToriAllowRemoteOrigin().text, "Hello, World!") | ||
} | ||
|
||
|
||
static var allTests : [(String, (ToriAllowRemoteOriginTests) -> () throws -> Void)] { | ||
return [ | ||
("testExample", testExample), | ||
] | ||
} | ||
} |