Flatten futures
This commit is contained in:
parent
d634e9c6ae
commit
a8cf77ec7c
|
@ -51,14 +51,15 @@ public struct GzipServerMiddleware: Middleware, ServiceType {
|
||||||
return stream.write(.chunk(buffer))
|
return stream.write(.chunk(buffer))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
write.always {
|
_ = write.flatMap {
|
||||||
buffer.clear()
|
buffer.clear()
|
||||||
buffer.write(integer: crc32, endianness: .little)
|
buffer.write(integer: crc32, endianness: .little)
|
||||||
buffer.write(integer: UInt32(data.count), endianness: .little)
|
buffer.write(integer: UInt32(data.count), endianness: .little)
|
||||||
stream.write(.chunk(buffer)).always {
|
return stream.write(.chunk(buffer))
|
||||||
_ = stream.write(.end)
|
}.flatMap {
|
||||||
}
|
return stream.write(.end)
|
||||||
}
|
}.transform(to: ())
|
||||||
|
|
||||||
let httpResponse = HTTPResponse(status: response.http.status, headers: headers, body: stream)
|
let httpResponse = HTTPResponse(status: response.http.status, headers: headers, body: stream)
|
||||||
return request.response(http: httpResponse)
|
return request.response(http: httpResponse)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user