Supported Flatform CocoaPods Carthage compatible Build Status

Just 是一个客户端 HTTP 库,其灵感来源于 python-requests - 为人类打造的 HTTP。

特性

Just 让您轻松地完成以下操作:

使用

使用 Just 的最简单请求如下所示:

//  A simple get request
Just.get("http://httpbin.org/get")

下一个示例展示了如何上传文件以及一些数据:

//  talk to registration end point
let r = Just.post(
    "http://justiceleauge.org/member/register",
    data: ["username": "barryallen", "password":"ReverseF1ashSucks"],
    files: ["profile_photo": .url(fileURLWithPath:"flash.jpeg", nil)]
)

if r.ok { /* success! */ }

这是以异步方式完成的相同示例:

//  talk to registration end point
Just.post(
    "http://justiceleauge.org/member/register",
    data: ["username": "barryallen", "password":"ReverseF1ashSucks"],
    files: ["profile_photo": .url(fileURLWithPath:"flash.jpeg", nil)]
) { r in
    if r.ok { /* success! */ }
}

阅读 入门指南 在网页上在此 playground 中 了解更多信息!

安装

以下是一些使用 Just 的方法:

Xcode

以通常的方式添加 https://github.com/dduan/Just.git

Swift Package Manager

将以下内容添加到您的 dependencies

.package(url: "https://github.com/dduan/Just.git",  from: "0.8.0")

…并将 "Just" 添加到您的 target dependencies。

Carthage

在您的 Cartfile 中包含以下内容:

github "dduan/Just"

Just 包括适用于 iOS 和 OS X 的动态 framework targets。

CocoaPods

以通常的方式

platform :ios, '8.0'
use_frameworks!

target 'MyApp' do
  pod 'Just'
end

手动

Just.xcodeproj 拖放到您的项目导航器中。 在项目设置的常规选项卡下,使用加号将 Just.framework 添加到链接框架和库。 确保包含适合您目标平台平台的正确版本。

将 Just 作为 git 子模块添加到您的项目存储库也很常见

cd path/to/your/project
git submodule add https://github.com/dduan/Just.git

源文件

Just.swift 直接放入您的项目中。 或者,将其放在 playground 的 Sources 文件夹中。(后者是探索网络的一种有趣方式。)

贡献

欢迎提交 Pull Request。 以下是一些给代码贡献者的提示:

Just.xcworkspace 中工作。

链接头部的测试依赖于 Github API,每个小时的限制很低。 为了克服这个问题,您可以编辑 Xcode 构建方案并添加 环境变量 GITHUB_TOKEN。 了解更多关于个人令牌的信息 这里

对于 Xcode rebels,请查看 Makefile

HTML 文档页面由文学编程工具 docco 生成

许可证

MIT,请参阅 LICENSE.md