Skip to content

Instantly share code, notes, and snippets.

@kuroyam
Last active August 28, 2015 09:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kuroyam/74b105f8826b460f14a8 to your computer and use it in GitHub Desktop.
Save kuroyam/74b105f8826b460f14a8 to your computer and use it in GitHub Desktop.
雑なやつ
class APIClient {
static func request(endpoint: Endpoint, parameters: Dictionary<String, String>?, handler: (result: Result) -> Void) {
// ここで通信
}
}
enum Endpoint {
case Login
case Feed(String, Method)
func path() -> String {
switch self {
case .Login: return "/login"
case .Feed(let id, let method): return "/users/\(id)/feed"
}
}
func method() -> Method {
switch self {
case .Login: return .POST
case .Feed(let id, let method): return method
}
}
}
enum Method {
case GET
case POST
case PUT
case DELETE
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment