Skip to content

nivsto/Just

This branch is 59 commits behind dduan/Just:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

81f1388 Â· Oct 29, 2016
Oct 21, 2016
Oct 29, 2016
Oct 11, 2016
Oct 8, 2016
Oct 27, 2016
Oct 29, 2016
Oct 11, 2016
Oct 9, 2016
Jun 29, 2016
Oct 9, 2016
Oct 29, 2016
May 1, 2015
Oct 28, 2016
Sep 18, 2016
Oct 8, 2016
Oct 29, 2016

Repository files navigation

Carthage compatible CocoaPods Build Status Supported Flatform

Just is a client-side HTTP library inspired by python-requests - HTTP for Humans.

Just supports Swift 3. You can use it with Swift 2 with version 0.4.8.

Follow @JustHTTP for updates, if you are into that kind of things 😉

Features

Just lets you to the following effortlessly:

  • URL queries
  • custom headers
  • form (x-www-form-encoded) / JSON HTTP body
  • redirect control
  • multipart file upload along with form values.
  • basic/digest authentication
  • cookies
  • timeouts
  • synchronous / asynchronous requests
  • upload / download progress tracking for asynchronous requests
  • link headers
  • friendly accessible results

Use

The simplest request with Just looks like this:

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

The next example shows how to upload a file along with some data:

//  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! */ }

Here's the same example done asynchronously:

//  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! */ }
}

Read Getting Started on the web or in this playground to learn more!

Install

Here are some ways to leverage Just.

Swift Package Manager

Add the following to your dependencies:

.Package(url: "https://github.com/JustHTTP/Just.git", majorVersion: 0, minor: 5)

Carthage (Swift 3 only)

Include the following in your Cartfile:

github "JustHTTP/Just"

Just includes dynamic framework targets for both iOS and OS X.

CocoaPods

The usual way:

platform :ios, '8.0'
use_frameworks!

target 'MyApp' do
  pod 'Just'
end

If you use Swift 2.3:

platform :ios, '8.0'
use_frameworks!

target 'MyApp' do
  pod 'Just', :git => 'https://github.com/JustHTTP/Just.git', :branch => 'swift-2.3'
end

Manual

Drop Just.xcodeproj into your project navigator. Under the General tab of your project settings, use the plus sign to add Just.framework to Linked Framework and Libraries. Make sure to include the correct version for your target's platform.

It's also common to add Just as a git submodule to your projects repository:

cd path/to/your/project
git submodule add https://github.org/JustHTTP/Just.git

Source File

Put Just.swift directly into your project. Alternately, put it in the Sources folder of a playground. (The latter makes a fun way to explore the web.)

Contribute

Pull requests are welcome. Here are some tips for code contributors:

Work in Just.xcworkspace.

The tests for link headers relies on Github APIs, which has a low per-hour limit. To overcome this, you can edit the Xcode build schemes and add environment variables GITHUB_TOKEN. Learn more about personal tokens here.

For Xcode rebels, checkout Makefile (you'll need xcpretty).

HTML documentation pages are generated by literate programmin tool docco

License

MIT, see LICENSE.md.

About

Swift HTTP for Humans

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 93.3%
  • Makefile 4.1%
  • Ruby 2.6%