All Projects → Meniny → Fire

Meniny / Fire

Licence: mit
🔥A delightful HTTP/HTTPS networking framework for iOS/macOS/watchOS/tvOS platforms written in Swift.

Programming Languages

swift
15916 projects
swift3
66 projects

Projects that are alternatives of or similar to Fire

Jsonify
♨️A delightful JSON parsing framework.
Stars: ✭ 42 (-82.72%)
Mutual labels:  mac, osx, tvos, watchos, macosx
Xcake
🍰 Describe Xcode projects in a human readable format and (re)generate one on demand.
Stars: ✭ 549 (+125.93%)
Mutual labels:  osx, tvos, watchos, cocoapods
Dknetworking
基于 AFNetworking + YYCache 的二次封装,支持缓存策略的网络请求框架
Stars: ✭ 41 (-83.13%)
Mutual labels:  network, networking, request, cocoapods
Alley
Essential `URLSessionDataTask` micro-wrapper for communication with HTTP(S) web services, with built-in automatic request retries.
Stars: ✭ 137 (-43.62%)
Mutual labels:  networking, tvos, watchos
Cloudkitgdpr
Framework for allowing users to manage data stored in iCloud
Stars: ✭ 126 (-48.15%)
Mutual labels:  tvos, watchos, cocoapods
Contentful.swift
A delightful Swift interface to Contentful's content delivery API.
Stars: ✭ 132 (-45.68%)
Mutual labels:  tvos, watchos, cocoapods
Swifterswift
A handy collection of more than 500 native Swift extensions to boost your productivity.
Stars: ✭ 10,706 (+4305.76%)
Mutual labels:  tvos, watchos, cocoapods
Iso8601
ISO8601 date parser and writer
Stars: ✭ 213 (-12.35%)
Mutual labels:  tvos, watchos, cocoapods
Ducttape
📦 KeyPath dynamicMemberLookup based syntax sugar for Swift.
Stars: ✭ 138 (-43.21%)
Mutual labels:  tvos, watchos, cocoapods
Powerkey
Remap your Macbook's power key to Forward Delete
Stars: ✭ 212 (-12.76%)
Mutual labels:  osx, mac, macosx
Macos Downloader
Command line tool for downloading macOS installers and beta updates
Stars: ✭ 162 (-33.33%)
Mutual labels:  osx, mac, macosx
Sqift
Powerful Swift wrapper for SQLite
Stars: ✭ 119 (-51.03%)
Mutual labels:  tvos, watchos, cocoapods
Macos Patcher
Command line tool for running macOS on unsupported Macs
Stars: ✭ 114 (-53.09%)
Mutual labels:  osx, mac, macosx
Evilosx
An evil RAT (Remote Administration Tool) for macOS / OS X.
Stars: ✭ 1,826 (+651.44%)
Mutual labels:  osx, mac, macosx
Alamofire
Elegant HTTP Networking in Swift
Stars: ✭ 36,896 (+15083.54%)
Mutual labels:  networking, request, cocoapods
Color
Color utilities for macOS, iOS, tvOS, and watchOS
Stars: ✭ 145 (-40.33%)
Mutual labels:  tvos, watchos, cocoapods
Version
Represent and compare versions via semantic versioning (SemVer) in Swift
Stars: ✭ 160 (-34.16%)
Mutual labels:  tvos, watchos, cocoapods
Criollo
A powerful Cocoa web framework and HTTP server for macOS, iOS and tvOS.
Stars: ✭ 229 (-5.76%)
Mutual labels:  osx, cocoapods, https
L10n Swift
Localization of the application with ability to change language "on the fly" and support for plural form in any language.
Stars: ✭ 177 (-27.16%)
Mutual labels:  tvos, watchos, cocoapods
Iglance
Free system monitor for OSX and macOS. See all system information at a glance in the menu bar.
Stars: ✭ 1,358 (+458.85%)
Mutual labels:  network, osx, mac

Fire
Version Author Build Passing  Swift
Platforms MIT
Cocoapods Carthage SPM


Introduction

What's this?

Fire is a delightful HTTP/HTTPS networking framework for iOS/macOS/watchOS/tvOS platform written in Swift and inspired by Python-Requests: HTTP for Humans.

Fire was written for humans to read, and incidentally, for machines to execute :)

Features

  • [x] Chainable Request / Response Methods
  • [x] Upload File / Data / MultipartFormData
  • [x] HTTP Basic Authorization
  • [x] TLS Certificate and Public Key Pinning
  • [x] Comprehensive Unit and Integration Test Coverage
  • [x] Synchronously/Asynchronously Request
  • [x] Timeouts
  • [x] Custom Cache Policy
  • [x] form (x-www-form-encoded)/JSON HTTP body

Requirements

  • iOS 8.0+
  • macOS 10.10+
  • watchOS 2.0+
  • tvOS 9.0+
  • Xcode 8 with Swift 3

Dependency

Installation

CocoaPods

pod 'Fire'

Contribution

You are welcome to fork and submit pull requests.

License

Fire is open-sourced software, licensed under the MIT license.

Usage

To send a request with Fire, you need to do 3 steps.

First, build up a Fire object:

let f = Fire.build(HTTPMethod: .GET, url: "https://yourdomain.com/get?l=zh")

Then, config the Fire object:

f.setParams(["key": "value"])
f.setFiles([file])
f.setHTTPHeaders(["Accept": "application/json"])
f.setBasicAuth("user", password: ")
f.setHTTPBody(raw: Data)
let certData = NSData(contentsOfFile: NSBundle.mainBundle().pathForResource("FireDemo", ofType: "cer")!)!
f.setSSLPinning(localCertData: certData) {
    print("Warning: Under Man-in-the-middle attack!!")
}
f.onError({ (resp, error) -> Void in
    print("Error: Network offline!")
})

Finally, fire up:

f.fire { (json, resp) -> Void in
    print(json["arg"]["key"].stringValue)
}

// or

f.fireForJSON { (json, resp) -> Void in
    print(json["arg"]["key"].stringValue)
}

// or

f.fireForString { (str, resp) -> Void in
    print(str)
}

// or

f.fireForData { (data, resp) -> Void in
    print("Success")
}

If you want to cancel it:

// cancel:
f.onCancel {
  print("Canceled")
}
f.cancel()
// or:
f.cancel {
   print("Canceled")
}

Use Fire.Dispatch if you want to send requests synchronously:

let f = Fire.build(HTTPMethod: .GET, url: api.stringValue, timeout: timeout, dispatch: .synchronously)

Fire.API:

open class func FireAPI1() {
    Fire.API.baseURL = FireDemo.BASEURL
    let api = Fire.API(appending: "get.php", HTTPMethod: .GET, successCode: .success)
    Fire.request(api: api, params: [:], timeout: 0, callback: { (json, resp) in
        if let status = resp?.statusCode {
            if status == api.successCode.rawValue {
                // ...
            }
        }
    }) { (error) in
        print(error.localizedDescription)
    }
}

open class func FireAPI2() {
    Fire.API.baseURL = FireDemo.BASEURL
    let api = Fire.API(appending: "get.php", HTTPMethod: .GET, successCode: .success)
    api.requestJSON(params: ["user": "Elias"], callback: { (json, resp) in
        if let status = resp?.statusCode {
            if status == api.successCode.rawValue {
                // ...
            }
        }
    }) { (error) in
        print(error.localizedDescription)
    }
}

open class func FireAPI3() {
    Fire.API.baseURL = FireDemo.BASEURL
    let api = Fire.API(appending: "get.php", HTTPMethod: .GET, headers: ["Content-Type": "text/json"], successCode: .success)
    api.requestJSON(params: ["userid": "1232"], headers: ["Device": "iOS"], timeout: 60, dispatch: .asynchronously, callback: { (json, resp) in
        if let status = resp?.statusCode {
            if status == api.successCode.rawValue {
                // ...
            }
        }
    }) { (error) in
        print(error.localizedDescription)
    }
}

中文介绍

这是什么?

Fire 一个使用 Swift 书写的轻量级 iOS/macOS/watchOS/tvOS 平台 HTTP/HTTPS 网络框架,深受 Python-Requests: HTTP for Humans 启发。

Fire 为了更好的可读性而生,碰巧还可以运行 :)

特性

  • [x] 链式调用的请求和响应方法
  • [x] 上传文件和数据
  • [x] 支持 HTTP Basic 认证
  • [x] 支持 SSL Pinning
  • [x] 全面的单元和集成测试覆盖
  • [x] 同步/异步请求
  • [x] 超时
  • [x] 自定义缓存策略
  • [x] 支持 form (x-www-form-encoded)/JSON HTTP 请求体

环境

  • iOS 8.0+
  • macOS 10.10+
  • watchOS 2.0+
  • tvOS 9.0+
  • Xcode 8 及 Swift 3

依赖

安装

CocoaPods

pod 'Fire'

贡献

欢迎任何人提交代码和问题。

协议

Fire 是一个开源软体,遵循 MIT 协议。

使用

要使用 Fire 发送请求,你只需要三个步骤。

首先,构建一个 Fire 实例:

let f = Fire.build(HTTPMethod: .GET, url: "https://yourdomain.com/get?l=zh")

然后,进行一些配置:

f.setParams(["key": "value"])
f.setFiles([file])
f.setHTTPHeaders(["Accept": "application/json"])
f.setBasicAuth("user", password: ")
f.setHTTPBody(raw: Data)
let certData = NSData(contentsOfFile: NSBundle.mainBundle().pathForResource("FireDemo", ofType: "cer")!)!
f.setSSLPinning(localCertData: certData) {
    print("Warning: Under Man-in-the-middle attack!!")
}
f.onError({ (resp, error) -> Void in
    print("Error: Network offline!")
})

最后,发起请求:

f.fire { (json, resp) -> Void in
    print(json["arg"]["key"].stringValue)
}

// or

f.fireForJSON { (json, resp) -> Void in
    print(json["arg"]["key"].stringValue)
}

// or

f.fireForString { (str, resp) -> Void in
    print(str)
}

// or

f.fireForData { (data, resp) -> Void in
    print("Success")
}

如果你需要取消请求:

// cancel:
f.onCancel {
  print("Canceled")
}
f.cancel()
// or:
f.cancel {
   print("Canceled")
}

如果你想发送同步请求, 请使用 Fire.Dispatch:

let f = Fire.build(HTTPMethod: .GET, url: api.stringValue, timeout: timeout, dispatch: .synchronously)

Fire.API:

open class func FireAPI1() {
    Fire.API.baseURL = FireDemo.BASEURL
    let api = Fire.API(appending: "get.php", HTTPMethod: .GET, successCode: .success)
    Fire.request(api: api, params: [:], timeout: 0, callback: { (json, resp) in
        if let status = resp?.statusCode {
            if status == api.successCode.rawValue {
                // ...
            }
        }
    }) { (error) in
        print(error.localizedDescription)
    }
}

open class func FireAPI2() {
    Fire.API.baseURL = FireDemo.BASEURL
    let api = Fire.API(appending: "get.php", HTTPMethod: .GET, successCode: .success)
    api.requestJSON(params: ["user": "Elias"], callback: { (json, resp) in
        if let status = resp?.statusCode {
            if status == api.successCode.rawValue {
                // ...
            }
        }
    }) { (error) in
        print(error.localizedDescription)
    }
}

open class func FireAPI3() {
    Fire.API.baseURL = FireDemo.BASEURL
    let api = Fire.API(appending: "get.php", HTTPMethod: .GET, headers: ["Content-Type": "text/json"], successCode: .success)
    api.requestJSON(params: ["userid": "1232"], headers: ["Device": "iOS"], timeout: 60, dispatch: .asynchronously, callback: { (json, resp) in
        if let status = resp?.statusCode {
            if status == api.successCode.rawValue {
                // ...
            }
        }
    }) { (error) in
        print(error.localizedDescription)
    }
}

⽇本語

Fire とは何か?

Fire とは Swift で作られる iOS/macOS/watchOS/tvOSiプラットホーム HTTP/HTTPS の軽量なデータのインタネットフレームワーク(Internet-Framework)、Python-Requests:HTTP for Humans に深い影響を与えられた。

人を理解やすくなるために、作られました。たまたまにプログラムを実行できる。

フィーチャー(Features)

  • [x] 連鎖されるリクエストとレスポンス のメソッド
  • [x] Upload file/data 可能
  • [x] HTTP Basic 認証をサポートしている
  • [x] SSL Pinning をサポートしている
  • [x] 全局と局部的なテスト可能
  • [x] 同期通信/非同期通信
  • [x] タイムアウト
  • [x] URLCachePolicy
  • [x] form (x-www-form-encoded)/JSON HTTP 制式をサポートしている

開発環境/動作環境

  • iOS 8.0 以上
  • macOS 10.10 以上
  • watchOS 2.0 以上
  • tvOS 9.0 以上
  • Xcode 8 / Swift 3 以上

インストール

CocoaPods

CocoaPods でライブラリをインストールします。

Podfile:

pod 'Fire'

プロジェクトのディレクトリ内で以下を実行 pod install

ライセンス

関連するリポジトリ含め、すべてMITです。詳細は各リポジトリ内のLICENSEをご覧ください。

貢献ガイド、サポート情報、ご留意事項

@渋谷の猫

(※準備中です)

開発/ビルド方法/使用方法

  1. Fire.build
let f = Fire.build(HTTPMethod: .GET, url: "https://yourdomain.com/get?l=zh")
  1. set.../add...
f.setParams(["key": "value"])
f.setFiles([file])
f.setHTTPHeaders(["Accept": "application/json"])
f.setBasicAuth("user", password: ")
f.setHTTPBody(raw: Data)
let certData = NSData(contentsOfFile: NSBundle.mainBundle().pathForResource("FireDemo", ofType: "cer")!)!
f.setSSLPinning(localCertData: certData) {
    print("Warning: Under Man-in-the-middle attack!!")
}
f.onError({ (resp, error) -> Void in
    print("Error: Network offline!")
})
  1. fire { (...) in }
f.fire { (json, resp) -> Void in
    print(json["arg"]["key"].stringValue)
}

// or

f.fireForJSON { (json, resp) -> Void in
    print(json["arg"]["key"].stringValue)
}

// or

f.fireForString { (str, resp) -> Void in
    print(str)
}

// or

f.fireForData { (data, resp) -> Void in
    print("Success")
}
// cancel:
f.onCancel {
  print("Canceled")
}
f.cancel()
// or:
f.cancel {
   print("Canceled")
}

Fire.Dispatch:

let f = Fire.build(HTTPMethod: .GET, url: api.stringValue, timeout: timeout, dispatch: .synchronously)

Fire.API:

open class func FireAPI1() {
    Fire.API.baseURL = FireDemo.BASEURL
    let api = Fire.API(appending: "get.php", HTTPMethod: .GET, successCode: .success)
    Fire.request(api: api, params: [:], timeout: 0, callback: { (json, resp) in
        if let status = resp?.statusCode {
            if status == api.successCode.rawValue {
                // ...
            }
        }
    }) { (error) in
        print(error.localizedDescription)
    }
}

open class func FireAPI2() {
    Fire.API.baseURL = FireDemo.BASEURL
    let api = Fire.API(appending: "get.php", HTTPMethod: .GET, successCode: .success)
    api.requestJSON(params: ["user": "Elias"], callback: { (json, resp) in
        if let status = resp?.statusCode {
            if status == api.successCode.rawValue {
                // ...
            }
        }
    }) { (error) in
        print(error.localizedDescription)
    }
}

open class func FireAPI3() {
    Fire.API.baseURL = FireDemo.BASEURL
    let api = Fire.API(appending: "get.php", HTTPMethod: .GET, headers: ["Content-Type": "text/json"], successCode: .success)
    api.requestJSON(params: ["userid": "1232"], headers: ["Device": "iOS"], timeout: 60, dispatch: .asynchronously, callback: { (json, resp) in
        if let status = resp?.statusCode {
            if status == api.successCode.rawValue {
                // ...
            }
        }
    }) { (error) in
        print(error.localizedDescription)
    }
}