GitHub - aaayia/AYINetwork: 基于Alamofire的swift网络库 · GitHub
Skip to content

aaayia/AYINetwork

Folders and files

Repository files navigation

AYINetwork

CI Status Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

swift='3.2'

Installation

AYINetwork is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'AYINetwork'

Example

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
            }
        }

Author

aaayia, twilightzzy@126.com

License

AYINetwork is available under the MIT license. See the LICENSE file for more info.

About

基于Alamofire的swift网络库

Resources

License

Stars

Watchers

Forks

Packages

Contributors