Skip to content
This repository has been archived by the owner on Apr 7, 2022. It is now read-only.

Commit

Permalink
Make the HTTPMessageDecoder.decode extension method public (#359)
Browse files Browse the repository at this point in the history
* Make the `HTTPMessageDecoder.decode` extension method public

* Update HTTPMessageCoder.swift

* Update HTTPMessageCoder.swift
  • Loading branch information
MrMage authored and tanner0101 committed Apr 4, 2019
1 parent 8da7d47 commit 254a0a0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Sources/HTTP/Codable/HTTPMessageCoder.swift
Expand Up @@ -43,7 +43,7 @@ public protocol HTTPMessageDecoder {
extension HTTPMessageDecoder {
/// See `HTTPMessageDecoder`.
/// - note: This method will use a default max size of 1MB.
func decode<D, M>(_ decodable: D.Type, from message: M, on worker: Worker) throws -> Future<D>
public func decode<D, M>(_ decodable: D.Type, from message: M, on worker: Worker) throws -> Future<D>
where D: Decodable, M: HTTPMessage
{
return try decode(D.self, from: message, maxSize: 1_000_000, on: worker)
Expand Down Expand Up @@ -96,7 +96,7 @@ extension JSONDecoder: HTTPMessageDecoder {
public func decode<D, M>(_ decodable: D.Type, from message: M, maxSize: Int, on worker: Worker) throws -> EventLoopFuture<D>
where D: Decodable, M: HTTPMessage
{
guard message.contentType == .json else {
guard message.contentType == .json || message.contentType == .jsonAPI else {
throw HTTPError(identifier: "contentType", reason: "HTTP message did not have JSON-compatible content-type.")
}
return message.body.consumeData(max: maxSize, on: worker).map(to: D.self) { data in
Expand Down

0 comments on commit 254a0a0

Please sign in to comment.