Protocols
The following protocols are available globally.
-
A protocol that credentials must implement to be used in KituraKit routes.
Classes or structs that conform to
ClientCredentials
must contain agetHeaders()
function that will return the HTTP headers required to authenticate using the provided credentials.Usage Example:
See morepublic struct MyToken: ClientCredentials { public let token: String public func getHeaders() -> [String : String] { return ["X-token-type": "MyToken", "access_token": self.token] } } client.get("/protected", credentials: MyToken(token: "12345")) { (user: User?, error: RequestError?) -> Void in guard let user = user else { print("failed request") } print(user) }
Declaration
Swift
public protocol ClientCredentials