Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/meniny/cria

An elegant HTTP requests framework for Swift with ❤️ and Alamofire + Promise. ☁️
https://github.com/meniny/cria

alamofire http https ios macos promise tvos

Last synced: about 1 month ago
JSON representation

An elegant HTTP requests framework for Swift with ❤️ and Alamofire + Promise. ☁️

Awesome Lists containing this project

README

        

:name: Cria
:author: Elias Abel
:author_esc: Elias%20Abel
:mail: [email protected]
:desc: an elegant HTTP requests framework for Swift with ❤️ and Alamofire + Promise ☁️
:icon: {name}.png
:version: 1.1.0
:na: N/A
:ios: 8.0
:macos: 10.10
:watchos: {na}
:tvos: 9.0
:linux: {na}
:xcode: 10.2
:swift: 5
:license: MIT
:sep: %20%7C%20
:platform: iOS{sep}macOS{sep}tvOS
// :toc: left
:toclevels: 6
:toc-title: TOC
:source-highlighter: highlightjs
// :source-highlighter: pygments
= Meet `{name}`
{author} <{mail}>
v{version}, 2019-04-21

[subs="attributes"]
++++


{name}



Author
EMail
MIT


Version
Platforms
Swift


Build Passing
Cocoapods
Carthage
SPM


++++

:toc:

== 🏵 Introduction

**{name}** is {desc}.

NOTE: `Cria` means a juvenile alpaca, also commonly known as `草泥马` in Mandarin Chinese.

== 📋 Requirements

[%header]
|===
2+^m|Type 1+^m|Requirement

1.5+^.^|Platform ^|iOS ^|{ios}
^|macOS ^|{macos}
^|tvOS ^|{tvos}
^|watchOS ^|{watchos}
^|Linux ^|{linux}

^|IDE ^|Xcode ^| {xcode}
^|Language ^|Swift ^| {swift}
|===

== 📲 Installation

=== CocoaPods

`{name}` is available on link:https://cocoapods.org[CocoaPods].

[source, ruby, subs="verbatim,attributes"]
----
use_frameworks!
pod '{name}'
----

=== Manually

Copy all files in the `{name}` directory into your project.

== 🛌 Dependency

* link:https://github.com/Meniny/Oath[Oath]
* link:https://github.com/Alamofire/Alamofire[Alamofire]

== ❤️ Contribution

You are welcome to fork and submit pull requests.

== 🔖 License

`{name}` is open-sourced software, licensed under the link:./LICENSE.md[`{license}`] license.

== 🔫 Usage

[source, swift, subs="verbatim,attributes"]
----
import {name}
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)
}
----

For `multipart-form`:

[source, swift, subs="verbatim,attributes"]
----
import {name}
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)
}
}
----