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 request

    Parameter

    Parameter response: the router response

    Parameter

    Parameter next: the closure for the next execution block

    Declaration

    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 socket

    Parameter

    Parameter contentType: the contentType as a string

    Returns

    the parsed body

    Declaration

    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 reader

    Throws

    ???

    Returns

    data for the body

    Declaration

    Swift

    public class func readBodyData(with reader: RouterRequest) throws -> Data

    Parameters

    with

    the socket reader

    Return Value

    data for the body