Skip to content
This repository was archived by the owner on Nov 23, 2021. It is now read-only.

GCD based, Asynchronous Implementation of the API #96

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,5 @@ fastlane/test_output
/Package.pins
/Package.resolved
docs
.build-linux

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The following code implements a very simple "Hello World!" server:
import Foundation
import HTTP

func hello(request: HTTPRequest, response: HTTPResponseWriter ) -> HTTPBodyProcessing {
func hello(request: HTTPRequest, response: HTTPResponseWriter, queue: DispatchQueue ) -> HTTPBodyProcessing {
response.writeHeader(status: .ok)
response.writeBody("Hello, World!")
response.done()
Expand All @@ -36,7 +36,7 @@ The following code implements a very simple Echo server that responds with the c
import Foundation
import HTTP

func echo(request: HTTPRequest, response: HTTPResponseWriter ) -> HTTPBodyProcessing {
func echo(request: HTTPRequest, response: HTTPResponseWriter, queue: DispatchQueue ) -> HTTPBodyProcessing {
response.writeHeader(status: .ok)
return .processBody { (chunk, stop) in
switch chunk {
Expand Down
6 changes: 3 additions & 3 deletions Sources/HTTP/HTTPCommon.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// See http://swift.org/LICENSE.txt for license information
//

import Foundation
import Dispatch

/// Typealias for a closure that handles an incoming HTTP request
/// The following is an example of an echo `HTTPRequestHandler` that returns the request it receives as a response:
Expand All @@ -32,7 +32,7 @@ import Foundation
/// - Parameter req: the incoming HTTP request.
/// - Parameter res: a writer providing functions to create an HTTP reponse to the request.
/// - Returns HTTPBodyProcessing: a enum that either discards the request data, or provides a closure to process it.
public typealias HTTPRequestHandler = (HTTPRequest, HTTPResponseWriter) -> HTTPBodyProcessing
public typealias HTTPRequestHandler = (HTTPRequest, HTTPResponseWriter, DispatchQueue) -> HTTPBodyProcessing

/// Class protocol containing a `handle()` function that implements `HTTPRequestHandler` to respond to incoming HTTP requests.
/// - See: `HTTPRequestHandler` for more information
Expand All @@ -42,7 +42,7 @@ public protocol HTTPRequestHandling: class {
/// - Parameter response: a writer providing functions to create an HTTP response to the request.
/// - Returns HTTPBodyProcessing: a enum that either discards the request data, or provides a closure to process it.
/// - See: `HTTPRequestHandler` for more information
func handle(request: HTTPRequest, response: HTTPResponseWriter) -> HTTPBodyProcessing
func handle(request: HTTPRequest, response: HTTPResponseWriter, queue: DispatchQueue) -> HTTPBodyProcessing
}

/// The result returned as part of a completion handler
Expand Down
Loading