Requestable
public protocol Requestable
A Requestable is an interfaces for types that express the details of an HTTP request
Types that conform to Requestable can be used as a paramater in RequestManager‘s makeRequest method, to create an observable combine publisher.
Requestable is a generic procol that requires to you specify the request body, respose body, and error model.
Depending on what types you use to specialize the protocol, parts of the interface maybe already implemented for you. See the documentation on each protocol requirement for more information.
-
The body type to be sent with this request
Declaration
Swift
associatedtype RequestBody -
The body type to expect from the response
Declaration
Swift
associatedtype ResponseBody -
Error generated by a response
Declaration
Swift
associatedtype ResponseError : Error
-
The specialized response to be returned by this request
Declaration
Swift
typealias Response = RequestResponse<ResponseBody> -
The specialized error to be generated by this request
Declaration
Swift
typealias Failure = RequestError<ResponseError>
-
The path to request
Declaration
Swift
var path: String { get } -
queryDefault implementationThe URL query to request A default empty url query is implemented for you
Default Implementation
Declaration
Swift
var query: [URLQueryItem] { get } -
The HTTP method to use
Declaration
Swift
var method: RequestMethod { get } -
The HTTP headers to send
Declaration
Swift
var headers: RequestHeaders { get } -
The body to append to the request
Declaration
Swift
var body: RequestBody? { get } -
authenticationDefault implementationUndocumented
Default Implementation
Undocumented
Declaration
Swift
var authentication: RequestAuthentication? { get } -
fallbackResponseDefault implementationThe response to use if the request fails A default fallback response of
nilis implemented for you.Default Implementation
Declaration
Swift
var fallbackResponse: Response? { get } -
Encoder used to encode
RequestBodyintoDataA default encoder is provided for you whenRequestBodyis one of the following:StringDataAnyJSONRequestParameters- Types that conform to
Encodable - Types that conform to
AutomaticBodyEncoding
Declaration
Swift
var requestEncoder: BodyEncoder<RequestBody> { get } -
Decoder used to decode
DataintoResponseBodyA default decoder is provided for you whenResponseBodyis one of the following:StringDataAnyJSON- Types that conform to
Decodable - Types that conform to
AutomaticBodyDecoding
Declaration
Swift
var responseDecoder: BodyDecoder<ResponseBody> { get } -
responseValidatorDefault implementationValidator used to check a fully constructoed
RequestResponsefor errors A default validator is implemented for you that automatically accepts all response as valid and makes no manipulationsDefault Implementation
Declaration
Swift
var responseValidator: ResponseValidator<ResponseBody, ResponseError> { get } -
timeoutIntervalDefault implementationInterval before the
RequestManagertimes out. A default timeout interval of 120 seconds is implemented for youDefault Implementation
Declaration
Swift
var timeoutInterval: TimeInterval { get }
View on GitHub
Install in Dash
Requestable Protocol Reference