Last active
September 23, 2019 07:10
-
-
Save SwiftyAlex/555c786f25206989ec1a2f728aa34cf3 to your computer and use it in GitHub Desktop.
Route Protocol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public protocol Route { | |
/// Request & ResponseType are forced, but `Empty` allows you to skip encoding/decoding | |
associatedtype RequestType: Encodable | |
associatedtype ResponseType: Decodable | |
static var method: HTTPMethod { get } | |
static var path: String { get } | |
static var requiresAuth: Bool { get } | |
/// Optional instance of `RequestType` that gets encoded if present | |
var requestObject: RequestType? { get set } | |
/// Any query parameters. | |
var queryParemeters: [URLQueryItem] { get set } | |
/// Any path items that we can then encode to the request string. These will be appended in the order they are found within the array | |
var pathParameters: [String] { get } | |
/// This function has a generic implenetation for the more simple routes, all others should have their own. | |
func toRequest() -> URLRequest | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment