Back to Kitura

ParsedBody

docs/docsets/Kitura.docset/Contents/Resources/Documents/Enums/ParsedBody.html

3.0.13.5 KB
Original Source

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

`

                urlEncoded(_:)
                `

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])

`

                urlEncodedMultiValue(_:)
                `

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]])

`

                text(_:)
                `

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)

`

                multipart(_:)
                `

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])

`

                json(_:)
                `

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])

`

                asJSON
                `

Extract a “JSON” body from the ParsedBody enum

Declaration

Swift

public var asJSON: [String : Any]? { get }

Return Value

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

`

                asMultiPart
                `

Extract a “multipart” body from the ParsedBody enum

Declaration

Swift

public var asMultiPart: [Part]? { get }

Return Value

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

`

                asRaw
                `

Extract a “raw” body from the ParsedBody enum

Declaration

Swift

public var asRaw: Data? { get }

Return Value

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

`

                asText
                `

Extract a “text” body from the ParsedBody enum

Declaration

Swift

public var asText: String? { get }

Return Value

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

`

                asURLEncoded
                `

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

Declaration

Swift

public var asURLEncoded: [String : String]? { get }

Return Value

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

`

                asURLEncodedMultiValue
                `

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

Declaration

Swift

public var asURLEncodedMultiValue: [String : [String]]? { get }

Return Value

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