BodyParser
public class BodyParser: RouterMiddleware
-
Initializes a BodyParser instance Needed since default initalizer is internal
Declaration
Swift
public init()
-
Handle the request
Parameter
Parameter request: the router requestParameter
Parameter response: the router responseParameter
Parameter next: the closure for the next execution blockDeclaration
Swift
public func handle(request: RouterRequest, response: RouterResponse, next: () -> Void) throws
Parameters
request
the router request
response
the router response
next
the closure for the next execution block
-
Parse the incoming message
Parameter
Parameter message: message coming from the socketParameter
Parameter contentType: the contentType as a stringReturns
the parsed bodyDeclaration
Swift
public class func parse(_ message: RouterRequest, contentType: String?) -> ParsedBody?
Parameters
message
message coming from the socket
contentType
the contentType as a string
Return Value
the parsed body
-
Read the Body data
Parameter
Parameter with: the socket readerThrows
???Returns
data for the bodyDeclaration
Swift
public class func readBodyData(with reader: RouterRequest) throws -> Data
Parameters
with
the socket reader
Return Value
data for the body