Structures

The following structures are available globally.

  • Struct to store client certificate name and path

    See more

    Declaration

    Swift

    public struct ClientCertificate
  • A struct for providing HTTP basic credentials to a KituraKit route. The struct is initialized with a username and password, which will be used to authenticate the user. This client route mirrors a Kitura Codable route that implements TypeSafeHTTPBasic authentication to verify a users identity.

    Usage Example:

    struct User: Codable {
       let name: String
    }
    
    client.get("/protected", credentials: HTTPBasic(username: "John", password: "12345")) { (user: User?, error: RequestError?) -> Void in
       guard let user = user else {
           print("failed request: \(error)")
       }
       print("Successfully authenticated and recieved \(user)")
    }
    
    See more

    Declaration

    Swift

    public struct HTTPBasic : ClientCredentials
  • A struct for providing a Facebook Oauth token as credentials to a KituraKit route. The struct is initialized with a token, which will be used to authenticate the user and generate their user profile. This client route mirrors a Kitura Codable route that implements TypeSafeFacebookToken authentication to verify a users identity.

    Usage Example:

    struct User: ExampleProfile {
       let id: String
       let name: String
       let email: String?
    }
    
    client.get("/facebookProfile", credentials: FacebookToken(token: "exampleToken")) { (user: ExampleProfile?, error: RequestError?) -> Void in
       guard let user = user else {
           print("failed request: \(error)")
       }
       print("Successfully authenticated and recieved \(user)")
    }
    
    See more

    Declaration

    Swift

    public struct FacebookToken : ClientCredentials
  • A struct for providing a Google Oauth token as credentials to a KituraKit route. The struct is initialized with a token, which will be used to authenticate the user and generate their user profile. This client route mirrors a Kitura Codable route that implements TypeSafeGoogleToken authentication to verify a users identity.

    Usage Example:

    struct User: ExampleProfile {
       let id: String
       let name: String
       let email: String?
    }
    
    client.get("/googleProfile", credentials: GoogleToken(token: "exampleToken")) { (user: ExampleProfile?, error: RequestError?) -> Void in
       guard let user = user else {
           print("failed request: \(error)")
       }
       print("Successfully authenticated and recieved \(user)")
    }
    
    See more

    Declaration

    Swift

    public struct GoogleToken : ClientCredentials
  • A struct for providing a JWT as credentials to a KituraKit route. The struct is initialized with a token, which will be used to authenticate the user and generate their user profile.

    Usage Example:

    struct JWTUser: Codable {
       let name: String
    }
    
    client.get("/protected", credentials: JWTCredentials(token: "exampleToken")) { (user: JWTUser?, error: RequestError?) -> Void in
       guard let user = user else {
           print("failed request: \(error)")
       }
       print("Successfully authenticated and recieved \(user)")
    }
    
    See more

    Declaration

    Swift

    public struct JWTCredentials : ClientCredentials
  • A type used to indicate that no credentials should be passed for this request. This can be used to override the default credentials for a client, to prevent those credentials from being used for a particular request.

    Usage Example:

    client.get("/public", credentials: NilCredentials()) { (response: MyResponse?, error: RequestError?) -> Void in
        guard let response = response else {
            print("failed request: \(error)")
        }
        print("Successfully recieved \(response)")
    }
    
    See more

    Declaration

    Swift

    public struct NilCredentials : ClientCredentials