EndpointBuilder
public struct EndpointBuilder
Convenience endpoint builder handler
-
Instantiate the builder for the provided setup
Declaration
Swift
public init(endpointSetup: APIEndpoint)Parameters
endpointSetuproot endpoint setup from where all builder setup will bootstrap
-
Assembles an URL for the current host
Example of usage:
let githubEndpoint = APIEndpoint(host: "github.com") let endpointBuilder = EndpointBuilder(endpointSetup: githubEndpoint) endpointBuilder.assembleRequest(path: "events") { result in switch(result) in case success(let assembledRequest): // do whatever you wish with URLRequest resulting type case failure(let errorType): // defaults to an URLRequest for google.com }Declaration
Swift
public func assembleRequest(path: String, queryParameters: [String : String] = [:]) -> URLRequestParameters
pathpath for the desired endpoint
queryParametersURL’s query parameters, should they exist. Defaults to an empty dictionary (no parameters)
Return Value
valid URL (defaults to google.com in case of error in assembly)
View on GitHub
EndpointBuilder Structure Reference