ResponseBodyDecodingStrategy
public protocol ResponseBodyDecodingStrategy
A protocol for defining strategies for handling response bodies.
Implement this protocol to create custom strategies for handling response bodies.
Example usage:
public class SpecificStatusCodeDecodingStrategy: ResponseBodyDecodingStrategy {
public static func allowsEmptyContent(for statusCode: Int) -> Bool {
return statusCode == 204 // your own statusCode value
}
}
-
Indicates whether the decoding should fail when no content is returned or not.
Use this property in a custom strategy implementation (example below) to check against the response’s
statusCode
and determine whether or not it should fail when receiving empty data.Declaration
Swift
static func allowsEmptyContent(for statusCode: Int) -> Bool
Parameters
statusCode
The HTTP status code of the response.
Return Value
A Boolean value indicating whether empty content is allowed.
-
Validates the HTTP status code to determine if it is within the acceptable range.
Declaration
Swift
static func validate(statusCode: Int) -> Bool
Parameters
statusCode
The HTTP status code of the response.
Return Value
A Boolean value indicating whether the status code is valid.