Cria 1.1.0

Cria 1.1.0

Meniny 维护。



 
依赖项
Oath>= 0
Alamofire~> 4.7
 

Cria 1.1.0

认识 Cria

Cria

Author EMail MIT
Version Platforms Swift
Build Passing Cocoapods Carthage SPM

🏵简介

Cria 是一个优雅的 Swift HTTP 请求框架,具有❤️以及 Alamofire + Promise☁️.

注意
Cria 是一种年轻的羊驼,在中文中通常称为 草泥马

📋要求

类型 要求

平台

iOS

8.0

macOS

10.10

tvOS

9.0

watchOS

不适用

Linux

不适用

IDE

Xcode

10.2

语言

Swift

5

📲安装

CocoaPods

CriaCocoaPods 上可用。

use_frameworks!
pod 'Cria'

手动

Cria 目录中的所有文件复制到您的项目中。

🛌依赖项

❤️贡献

欢迎您 Fork 并提交 Pull Request。

🔖许可证

Cria 是开源软件,许可协议为 MIT 许可。

🔫用法

import Cria
import Oath

let cria = Cria.init("https://meniny.cn/api/v2/")

// A simple get request:
cria.get("posts.json").then { response in
        print("Done: ", response.code)
    }.onError { error in
        print("Error: ", error.localizedDescription)
}

// or:
cria.do(.get, path: "posts.json").then { response in
        print("Done: ", response.code)
    }.onError { error in
        print("Error: ", error.localizedDescription)
}

对于 multipart-form

import Cria
import Oath

let cria = Cria.init("https://some-domain.com/")

let image = #imageLiteral(resourceName: "Cria")
if let data = UIImageJPEGRepresentation(image, 1) {
    let part = CriaFormPart.init(.data(data), name: "image", mimetype: "image/jpeg")
    cria.postMultipart("some_uploading_api/subpath/", data: [part]).progress { p in
        print("Progress: ", p)
        }.then { response in
            print("Done: ", response.code)
        }.onError { error in
            print("Error: ", error.localizedDescription)
    }
}