Skip to content
This repository has been archived by the owner on Sep 24, 2020. It is now read-only.

vsouza/Wings

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Wings

Pure Swift cURL Requests.

Swift Version Build Status License codebeat-badge

Inspired on Python Requests.

A beautiful HTTP Client for your Swift projects.

Installation

Add this project on your Package.swift

import PackageDescription

let package = Package(
    dependencies: [
        .Package(url: "https://github.com/vsouza/wings.git", majorVersion: 0, minor: 0)
    ]
)

Usage example

GET

import Wings
let w = Wings()
if let response = w.get(url:"http://localhost:8080/", headers:nil){

  print(response) \\ Response() struct type

  print(response.headers) \\ list of headers [AnyHashable : Any]?
  print(response.statusCode) \\ (Int?)

  print(response.json) \\ json response ([String: Any]?)
  print(response.text) \\ text response (String?)

}

POST JSON

import Wings

var headers: [String: String] = ["Content-Type": "application/json"]
var body : [String: Any] = ["owner": "vsouza"]
let jsonBody = try? JSONSerialization.data(withJSONObject: body)

let w = Wings()
if let response = w.post(url: "http://localhost:8080/", headers: headers, body:jsonBody) {
    if let json = response.json{
        print(json["owner"]) // vsouza
    }
}

Release History

  • 0.0.1
    • Work in progress

Meta

Vinicius Souza – @iamvsouzahi@vsouza.com

Distributed under the MIT license. See License

https://github.com/vsouza