Skip to content

Commit

Permalink
Merge pull request #315 from phimage/stable
Browse files Browse the repository at this point in the history
Add `data` to `HttpResponseBody`
  • Loading branch information
damian-kolakowski authored Jun 7, 2018
2 parents 0c48adb + 64c8382 commit 078cc0e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Sources/HttpResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)?) {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 078cc0e

Please sign in to comment.