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/json
this associated value will contain the body of a JSON object.Declaration
Swift
case json(JSON)
-
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
text
this associated value will contain a representation of the body as a String.Declaration
Swift
case text(String)
-
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])
-
Extract a
JSON
body from theParsedBody
enumReturns
The parsed body as a JSON object, or nil if the body wasn’t in JSON format.Declaration
Swift
public var asJSON: JSON?
Return Value
The parsed body as a JSON object, or nil if the body wasn’t in JSON format.
-
Extract a
multipart
body from theParsedBody
enumReturns
The parsed body as an array ofPart
structs, or nil if the body wasn’t in multi-part form format.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
text
body from theParsedBody
enumReturns
Thetext
body as a String, or nil if the body wasn’t in text format.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 theParsedBody
enumReturns
The parsed body as a Dictionary, or nil if the body wasn’t in url encoded form format. 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.