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
import XCTest | |
import Kitura | |
import Foundation | |
final class dataTaskTests: XCTestCase { | |
let router = Router() | |
func testExample() throws { | |
router.get("/", handler: getHandler) | |
Kitura.addHTTPServer(onPort: 8080, with: router) |
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
import Foundation | |
import Kitura | |
import LoggerAPI | |
import Configuration | |
import CloudEnvironment | |
import KituraContracts | |
import Health | |
import KituraSession | |
public let projectPath = ConfigurationManager.BasePath.project.path |
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
// Shared code | |
struct User: Codable { | |
let name: String | |
let age: Int | |
} | |
router.post("/users", handler: postHandler) | |
// Users codable route without result | |
func postHandler(user: User, completion: (User?, RequestError?) -> Void ) { | |
guard user.name == "Andy" else { |
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
// CouchDBClient | |
/// Returns a `UsersDatabase` instance. | |
public func usersDatabase() -> UsersDatabase { | |
return UsersDatabase(connProperties: self.connProperties, dbName: "_users") | |
} | |
// MARK: Config | |
/// Set a CouchDB configuration parameter to a new value. |
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
/* | |
* Copyright IBM Corporation 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 |
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
// ChatServer is a very simple chat server | |
import Foundation | |
import KituraWebSocket | |
import Foundation | |
class ChatService: WebSocketService { | |
private var connections = [String: ConnectionWrapper]() | |
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
// ChatServer is a very simple chat server | |
import Foundation | |
import KituraWebSocket | |
import Foundation | |
class ChatService: WebSocketService { | |
var gameTimer: Timer! | |
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
/** | |
* 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 |
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
/** | |
* 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 | |
* |