ParsedBody

public indirect enum ParsedBody

The result of parsing the body of the request.

When a body of a request is parsed the results of the parsing are placed in the associated value of the enum case based on Content-Type

  • If the content type was application/x-www-form-urlencoded this associated value will contain a representation of the body as a dictionary of key-value pairs.

    Declaration

    Swift

    case urlEncoded([String:String])
  • If the content type was application/x-www-form-urlencoded this associated value will contain a representation of the body as a dictionary of key-[value] pairs.

    Declaration

    Swift

    case urlEncodedMultiValue([String: [String]])
  • If the content type was text this associated value will contain a representation of the body as a String.

    Declaration

    Swift

    case text(String)
  • raw

    A raw representation of the body as a Data struct.

    Declaration

    Swift

    case raw(Data)
  • If the content type was multipart/form-data this associated value will contain an array of parts of multi-part respresentation of the body.

    Declaration

    Swift

    case multipart([Part])
  • If the content type was application/json this associated value will contain the body of a [String: Any] json dictionary object.

    Declaration

    Swift

    case json([String: Any])
  • Extract a JSON body from the ParsedBody enum

    Declaration

    Swift

    public var asJSON: [String: Any]?

    Return Value

    The parsed body as a [String: Any] object, or nil if the body wasn’t in JSON format.

  • Extract a multipart body from the ParsedBody enum

    Declaration

    Swift

    public var asMultiPart: [Part]?

    Return Value

    The parsed body as an array of Part structs, or nil if the body wasn’t in multi-part form format.

  • Extract a raw body from the ParsedBody enum

    Declaration

    Swift

    public var asRaw: Data?

    Return Value

    The raw body as a Data, or nil if the body wasn’t in raw format.

  • Extract a text body from the ParsedBody enum

    Declaration

    Swift

    public var asText: String?

    Return Value

    The text body as a String, or nil if the body wasn’t in text format.

  • Extract a urlEncoded body from the ParsedBody enum with comma- separated values.

    Declaration

    Swift

    public var asURLEncoded: [String:String]?

    Return Value

    The parsed body as a Dictionary, or nil if the body wasn’t in url encoded form format.

  • Extract a urlEncoded body from the ParsedBody enum with values in an array..

    Declaration

    Swift

    public var asURLEncodedMultiValue: [String: [String]]?

    Return Value

    The parsed body as a Dictionary>, or nil if the body wasn’t in url encoded form format.