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 Vapor | |
import SwiftProtobuf | |
import Foundation | |
extension Request { | |
public func decodeMessage<M: SwiftProtobuf.Message>(_ type: M.Type = M.self) throws -> M { | |
let data = http.body.data ?? Data() | |
if http.contentType == MediaType.json { | |
return try M(jsonUTF8Data: data) |