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
//matches route https://BASEURL/users/67 but not https://BASEURL/users/H67p | |
drop.get("users", Int.self) { request, userId in | |
return "You requested User #\(userId)" | |
} | |
//matches route https://BASEURL/players/67 if there is a persisted User in Database with id==67 |
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 PackageDescription | |
let package = Package( | |
name: "DockerSwiftBackend", | |
dependencies: [ | |
.Package(url: "https://github.com/necolt/Swifton.git", Version(0,0,5)), | |
.Package(url: "https://github.com/necolt/Curassow.git", versions: Version(0,4,0)..<Version(1,0,0)), | |
.Package(url: "git@GIT_REPO_URL_TO_SHAREDCODE", versions: Version(0,0,9)..<Version(1,0,0)), | |
] | |
) |
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 Swifton | |
import Curassow | |
let router = Router() | |
router.post("/login", LoginController() ["login"]) | |
serve { router.respond($0) } |
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
func performRequestWithUsername(username: String, password: String) { | |
let loginRequest = LoginRequest(userId: username, password: password) | |
let json = loginRequest.toJSON() | |
let urlRequest = NSMutableURLRequest( URL: NSURL(string: "https://SWIFT-WEBSERVICE-URL/login")!, | |
cachePolicy: .ReloadIgnoringLocalCacheData, | |
timeoutInterval: 60) | |
urlRequest.HTTPMethod = "POST" | |
urlRequest.setValue("application/json", forHTTPHeaderField: "Content-Type") | |
urlRequest.HTTPBody = try? json.rawData() |
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 | |
public class LoginResponse { | |
public var text: String = "" | |
public init (text: String) { | |
self.text = text | |
} |
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 | |
public class LoginRequest { | |
public var userId: String = "" | |
public var password: String = "" | |
public init(userId: String, password: String) { | |
self.userId = userId | |
self.password = password |
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
//"modern Objective-C" syntax | |
//new enum-macros for better autocompletion, switch statement, more precise warnings, ... | |
typedef NS_ENUM(NSInteger, MyViewContentMode) { | |
MyViewContentModeLeft, | |
MyViewContentModeRight, | |
MyViewContentModeTopLeft, | |
MyViewContentModeTopRight, |
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
- (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL{ | |
return [URL setResourceValue:[NSNumber numberWithBool:YES] forKey:NSURLIsExcludedFromBackupKey error:nil]; | |
} |
NewerOlder