Skip to content

Instantly share code, notes, and snippets.

@kuroyam
Created September 22, 2017 02:38
Show Gist options
  • Save kuroyam/384146c1b8ca7391a152677d67b90f4d to your computer and use it in GitHub Desktop.
Save kuroyam/384146c1b8ca7391a152677d67b90f4d to your computer and use it in GitHub Desktop.
import UIKit
protocol GETProtocol {
associatedtype GETArguments
static func get(_ args: GETArguments)
}
protocol POSTProtocol {
associatedtype POSTArguments
static func post(_ args: POSTArguments)
}
struct Endpoint: GETProtocol, POSTProtocol {
typealias GETArguments = Void
static func get(_ args: Void) {
print("get")
}
typealias POSTArguments = String
static func post(_ args: String) {
print("post: \(args)")
}
}
Endpoint.get() // get
Endpoint.post("hoge") // post: hoge
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment