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 }
-
query
Default 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 }
-
authentication
Default implementationUndocumented
Default Implementation
Undocumented
Declaration
Swift
var authentication: RequestAuthentication? { get }
-
fallbackResponse
Default implementationThe response to use if the request fails A default fallback response of
nil
is implemented for you.Default Implementation
Declaration
Swift
var fallbackResponse: Response? { get }
-
Encoder used to encode
RequestBody
intoData
A default encoder is provided for you whenRequestBody
is one of the following:String
Data
AnyJSON
RequestParameters
- Types that conform to
Encodable
- Types that conform to
AutomaticBodyEncoding
Declaration
Swift
var requestEncoder: BodyEncoder<RequestBody> { get }
-
Decoder used to decode
Data
intoResponseBody
A default decoder is provided for you whenResponseBody
is one of the following:String
Data
AnyJSON
- Types that conform to
Decodable
- Types that conform to
AutomaticBodyDecoding
Declaration
Swift
var responseDecoder: BodyDecoder<ResponseBody> { get }
-
responseValidator
Default implementationValidator used to check a fully constructoed
RequestResponse
for 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 }
-
timeoutInterval
Default implementationInterval before the
RequestManager
times out. A default timeout interval of 120 seconds is implemented for youDefault Implementation
Declaration
Swift
var timeoutInterval: TimeInterval { get }