Przeglądaj źródła

Add `data` to `HttpResponseBody`

Eric Marchand 8 lat temu
rodzic
commit
64c8382fc6
1 zmienionych plików z 5 dodań i 0 usunięć
  1. 5 0
      Sources/HttpResponse.swift

+ 5 - 0
Sources/HttpResponse.swift

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