|
@@ -25,6 +25,7 @@ public enum HttpResponseBody {
|
|
|
case json(AnyObject)
|
|
case json(AnyObject)
|
|
|
case html(String)
|
|
case html(String)
|
|
|
case text(String)
|
|
case text(String)
|
|
|
|
|
+ case data(Data)
|
|
|
case custom(Any, (Any) throws -> String)
|
|
case custom(Any, (Any) throws -> String)
|
|
|
|
|
|
|
|
func content() -> (Int, ((HttpResponseBodyWriter) throws -> Void)?) {
|
|
func content() -> (Int, ((HttpResponseBodyWriter) throws -> Void)?) {
|
|
@@ -56,6 +57,10 @@ public enum HttpResponseBody {
|
|
|
return (data.count, {
|
|
return (data.count, {
|
|
|
try $0.write(data)
|
|
try $0.write(data)
|
|
|
})
|
|
})
|
|
|
|
|
+ case .data(let data):
|
|
|
|
|
+ return (data.count, {
|
|
|
|
|
+ try $0.write(data)
|
|
|
|
|
+ })
|
|
|
case .custom(let object, let closure):
|
|
case .custom(let object, let closure):
|
|
|
let serialised = try closure(object)
|
|
let serialised = try closure(object)
|
|
|
let data = [UInt8](serialised.utf8)
|
|
let data = [UInt8](serialised.utf8)
|