[![Swift][swift-badge]][swift-url] [![Zewo][zewo-badge]][zewo-url] [![Platform][platform-badge]][platform-url] [![License][mit-badge]][mit-url] [![Slack][slack-badge]][slack-url]
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
public protocol Error: ErrorProtocol { | |
var status: Status { get } | |
} | |
public enum ClientError: Error { | |
case badRequest | |
case unauthorized | |
case paymentRequired | |
case forbidden | |
case notFound |
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
do { | |
let ip = try IP(localAddress: "127.0.0.1", port: 8080) | |
let serverSocket = try TCPServerSocket(ip: ip) | |
serverSocket.accept { getClientStream in | |
do { | |
let clientStream = try getClientStream() | |
clientStream.receive(length: Int.max) { getData in | |
do { | |
let data = try getData() |
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
public typealias Byte = UInt8 | |
public struct Data { | |
public var bytes: [Byte] | |
public init(_ bytes: [Byte]) { | |
self.bytes = bytes | |
} | |
} |
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: "S4", | |
dependencies: [ | |
.Package(url: "https://github.com/swiftx/http.git", majorVersion: 0, minor: 1, alias: "SwiftXHTTP"), | |
.Package(url: "https://github.com/Zewo/HTTP.git", majorVersion: 0, minor: 1, alias: "ZewoHTTP") | |
] | |
) |
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 Dispatch | |
import XCPlayground | |
XCPlaygroundPage.currentPage.needsIndefiniteExecution = true | |
func delay(duration: Double, closure: Void -> Void) { | |
let delayTime = dispatch_time(DISPATCH_TIME_NOW, Int64(duration * Double(NSEC_PER_SEC))) | |
dispatch_after(delayTime, dispatch_get_main_queue(), closure) | |
} |
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
let todoResources = Resource(middleware: recovery, contentNegotiaton) { todo in | |
todo.index { _ in | |
let todos = try app.getAllTodos() | |
return Response(content: ["todos": todos.content]) | |
} | |
todo.create(mappingTo: Todo.self) { request, todo in | |
let todo = try app.createTodo(todo) | |
return Response(content: todo) | |
} |
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
<FrameLayout | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content"> | |
<ImageView | |
android:id="@+id/backgroundImageView" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" |
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
<FrameLayout | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content"> | |
<ImageView | |
android:id="@+id/backgroundImageView" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" |