#SimpleHttpClient

Swift Platform Build Status Codacy Badge Coverage Status

安装

import PackageDescription

let package = Package(
    dependencies: [
        .Package(url: "https://github.com/ibm-bluemix-mobile-services/bluemix-simple-http-client-swift.git", majorVersion: 0, minor: 5)
    ]
)

设置

SimpleHttpClient 是 https://github.com/IBM-Swift/Kitura-net 之上的一个简单的抽象层。

构建

swift build -Xcc -fblocks -Xlinker -rpath -Xlinker $(pwd)/.build/debug

用法

import SimpleHttpClient

let httpResource = HttpResource(schema: "http", host: "httpbin.org", port: "80")
let headers = ["Content-Type":"application/json"];
let data = NSData()

let resource = httpResource.resourceByAddingPathComponent(pathComponent: "/post")
HttpClient.post(resource: resource, headers: headers, data: data) { (error, status, headers, data) in
    if error != nil {
        print("Failure")
    } else if let data = data {
        print("Success")
    }
}

许可证

版权所有 2016 IBM Corp.

根据 Apache License, Version 2.0(“许可证”)授权;除非遵守许可证,否则您不得使用此文件。 您可以在以下位置获得许可证的副本:

https://apache.ac.cn/licenses/LICENSE-2.0

除非适用法律要求或以书面形式达成协议,否则根据“按原样”基础分发的软件不附带任何形式的明示或暗示的保证或条件。 有关管理权限和限制的特定语言,请参阅许可证。