Protocols
The following protocols are available globally.
-
A type that provides an interface to create requests to an API.
Overview
For each API, create a type that conforms to
RequestProvidingand implement the base URL of the API. Using this type you can createRequests for the different endpoints of the API using the construction methods provided by the protocol.You can optionally implement the
request(to:using:)method to customize the default request provided by the other construction methods.See moreSee also
AnonymousRequestProviderDeclaration
Swift
public protocol RequestProviding
-
A type that can convert itself into a Foundation
URLRequest.Overview
Conforming types provide all the information needed to create a
URLRequestfor aResourcefrom an API. The associatedResourcetype is the type encoded in the body of the response to the request. Conforming types provide aResponseDecoder<Resource>that is responsible for transforming the raw response data into the associatedResourcefor the request.Conforming to the
RequestConvertibleProtocolConforming to the
RequestConvertibleprotocol requires you specify an associatedResourcetype and declare:- The base URL for the request.
- The endpoint for the request.
- The HTTP method for the request.
- The decoder for the associated resource type.
Default implementations of other properties are provided using the values defined in
DefaultValue. Where it can be inferred from theResourcetype, a defaultResponseDecoderis also provided.See moreNote
If your request does not expect a response body, set the associatedResourcetype toVoid.Declaration
Swift
public protocol RequestConvertible : CustomStringConvertible
View on GitHub
Protocols Reference