// MARK : Declare base URL
enum NetworkEnvironment {
case qa
case production
}
class APIEndPoint {
// MARK : Returning base URL
static var environmentBaseURL : String {
switch NetworkManager.environment {
case .production: return ""
case .qa: return "https://www.jsonkeeper.com/"
}
}
// MARK : Finally seted base URL for the end point
static var baseURL: String {
return environmentBaseURL
}
// MARK : List of sub URLs
static let homeURL = "b/12D8"
}
import Foundation
// MARK : Declare API request type
enum RequestMethod: String {
case get = "GET"
case post = "POST"
case put = "PUT"
case delete = "DELETE"
}
9条答案
按热度按时间voj3qocg1#
使用Alamofire非常简单。
通过使用
urlRequest
e5njpo682#
d5vmydt93#
URLRequest
type documentation概述了所有可以设置的不同属性。您需要创建一个URLRequest
示例,然后使用URLSession
来执行请求。rsl1atfo4#
带有标题字段
jucafojl5#
ct3nt3jp6#
lrpiutwd7#
ruarlubt8#
kkih6yb89#