Created
December 26, 2016 23:00
-
-
Save kitasuke/1e9f9d71490e8c970aeb9fad42458309 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import APIKit | |
protocol ProtobufRequest: Request {} | |
extension ProtobufRequest { | |
var dataParser: DataParser { | |
return ProtobufDataParser() | |
} | |
} | |
extension ProtobufRequest where Response: SwiftProtobuf.Message { | |
func response(from object: Any, urlResponse: HTTPURLResponse) throws -> Response { | |
guard let data = object as? Data else { | |
throw ResponseError.unexpectedObject(object) | |
} | |
return try Response(protobuf: data) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment