Skip to content

Commit

Permalink
first release
Browse files Browse the repository at this point in the history
  • Loading branch information
Matteo committed Aug 21, 2016
0 parents commit 729af4d
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.build
.vagrant
Packages
*.pkg
1 change: 1 addition & 0 deletions .swift-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DEVELOPMENT-SNAPSHOT-2016-07-25-a
8 changes: 8 additions & 0 deletions Package.swift
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)
]
)
32 changes: 32 additions & 0 deletions Sources/ToriAllowRemoteOrigin.swift
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()

}
}
6 changes: 6 additions & 0 deletions Tests/LinuxMain.swift
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 Tests/ToriAllowRemoteOrigin/ToriAllowRemoteOriginTests.swift
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),
]
}
}

0 comments on commit 729af4d

Please sign in to comment.