Skip to content

RequestComponents

Josh Wright edited this page Jan 14, 2021 · 3 revisions

RequestComponents

Represents the components needed to make an HTTP request.

public struct RequestComponents

Properties

method

The method of this request.

let method: EndpointMethod

headers

Any headers that may be on this request.

let headers: [String: String]

basePath

The base path of this request, without any path parameters replaced.

let basePath: String

query

The query string of this request.

let query: String

fullPath

The full path of this request, including any path parameters and the query string.

let fullPath: String

body

The body of this request.

let body: AnyEncodable?

bodyEncoding

Body encoding.

let bodyEncoding: BodyEncoding

Methods

just(url:method:)

Creates a simple RequestComponents with just a url and an endpoint method.

public static func just(url: String, method: EndpointMethod) -> RequestComponents

Parameters

  • url: The url of the request.
  • method: The method of the request.

Returns

The RequestComponents representing a request with the given url and method.

urlParams()

Creates a string representing any URL parameters this request should have. This returns nil if self.body is nil or it's content type is not .urlEncoded.

public func urlParams() throws -> String?

Throws

Any error encountered while encoding the self.body.content to a URL String.

Returns

The url parameters string of this request, or nil if it has none.

Alchemy
Types
Protocols
Global Typealiases
Global Variables
Global Functions
Fusion
Types
Protocols
Papyrus
Types
Protocols
Clone this wiki locally