微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Justhttp 轻量级 HTTP 客户端库

程序名称:Justhttp

授权协议: MIT

操作系统: iOS

开发语言: Swift

Justhttp 介绍

Just 是一款用 Swift 语言编写的,受 python-requests 影响的轻量级 HTTP 客户端库。

Just 可以让你毫不费力地完成如下工作:

用法

使用 Just 发起一个请求的例子:

//  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)
    if (r.ok) { /* success! */ }
}

你可以在这个
Playground

中了解更多 Just 库的使用方法

安装:

  • 代码文件:只须将唯一的一个文件拖入 playground 或者直接拖入到你的代码

  • Git 子模块:将改 repo 作为 Git 子模块添加到你的 git 项目中,然后拖动 Just.xcodeproj 到你的 Xcode 项目中以便你可以创建一个对 Just.framework 的依赖并且进行链接

  • 动态框架:因为 Just 是一个针对 OS X 和 iOS 的动态框架,所以 Carthage 就可以安装它。

作者邮箱:[email protected]

Justhttp 官网

https://github.com/justhttp/Just

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐