HTTPMethod
public enum HTTPMethod: String
An enumeration of the supported methods
-
Will generate POST requests for a given Restable
Declaration
Swift
case post = "POST"
-
Will generate GET requests for a given Restable
Declaration
Swift
case get = "GET"
-
Will gneerate a PUT request for a given Restable
Declaration
Swift
case put = "PUT"
-
Will generate a PATCH request for a given Restable
Declaration
Swift
case patch = "PATCH"
-
Will generate a DELETE request for a given restable
Declaration
Swift
case delete = "DELETE"
-
Creates a URLRequest appropriate for this instance
Throws
AnHTTPMethodError.invalidURLif theURLRequestcould not be created.Declaration
Swift
public func makeURLRequest<T>(`for` restable: T) throws -> URLRequest where T: RestableParameters
restableThe Restable for which a URLRequest is to be created
Return Value
The URLRequest for this Restable
-
Creates a URLRequest for this instance and uses the JSON Encoded data of this instance as the request’s body.
Throws
- An
HTTPMethodError.invalidURLif theURLRequestcould not be created. - An
HTTPMethodError.jsonSerializationFailed(error: Error)if the Restable fails to encode.
Declaration
Swift
public func makeURLRequest<T>(`for` restable: T) throws -> URLRequest where T: Restable & EncodableParameters
restableThe Restable for which a URLRequest is to be created
Return Value
The URLRequest for this Restable
- An
-
Creates a URLRequest for this instance and uses this instance’s
datavalue as the request’s body.Throws
AnHTTPMethodError.invalidURLif theURLRequestcould not be created.Declaration
Swift
public func makeURLRequest<T>(`for` restable: T) throws -> URLRequest where T: Restable & PreEncodedParameters
restableThe Restable for which a URLRequest is to be created
Return Value
The URLRequest for this Restable
-
JSON encodes the
Encodableinstance.Throws
throws an error based on the type of problem:- The value fails to encode, or contains a nested value that fails to encode—this method throws the corresponding error.
- The value can’t be encoded as a JSON array or JSON object—this method throws the invalidValue error.
- The value contains an exceptional floating-point number (such as infinity or nan) and you’re using the default JSONEncoder.NonConformingFloatEncodingStrategy—this method throws the invalidValue error.
Declaration
Swift
public func encode<T>(_ instance: T) throws -> Data where T: EncodableParameters
instanceThe
Encodableto be encodedReturn Value
The encoded data of
instance -
JSON encodes the
Encodableinstance.Throws
throws an error based on the type of problem:- The value fails to encode, or contains a nested value that fails to encode—this method throws the corresponding error.
- The value can’t be encoded as a JSON array or JSON object—this method throws the invalidValue error.
- The value contains an exceptional floating-point number (such as infinity or nan) and you’re using the default JSONEncoder.NonConformingFloatEncodingStrategy—this method throws the invalidValue error.
Declaration
Swift
public func encode<T>(_ instance: T) throws -> Data where T: Encodable & RestableParameters
instanceThe
Encodableto be encodedReturn Value
The encoded data of
instance
View on GitHub
HTTPMethod Enumeration Reference