To run the example project, clone the repo, and run pod install
from the Example directory first.
swift='3.2'
AYINetwork is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'AYINetwork'
struct HTTPTarget: WKTarget {
var baseURLString: String { return "http://127.0.0.1:8000" }
var headers: [String : String] = [:]
}
class LoginRequest: WKRequest {
let username = "zhangsan"
let password = "12345678"
override func loadRequest() {
super.loadRequest()
self.path = "/login"
self.method = .post
}
}
struct User: Decodable {
var id: Int
var name: String
var token: String
}
HTTPNetwork.request(LoginRequest()) { (response) in
if let user = response.decode(to:User.self) {
}else if response.error != nil {
//show error
}
}
aaayia, [email protected]
AYINetwork is available under the MIT license. See the LICENSE file for more info.