Requesto 0.0.4

Requesto 0.0.4

Pavserg 维护。



Requesto 0.0.4

  • Pavlo Dumiak

SwiftRequesto

Requesto是一个轻量级的iOS应用程序网络层,可以执行异步和同步的URLRequests。

首先,您需要导入它。

import Requester

对于常见的REST请求,请使用Request()。

示例

let request = Request(owner: ObjectIdentifier.init(self),
          url: "...your url...",
          requestType: .get,
          onSuccess: { response in
               //...response here
          }, onFail: { error in
               //...error here
          })

对于同步执行,使用

request.executeSync(parseAs: ...your type for parsing...)

对于异步执行,使用

request.executeAsync(parseAs: ...your type for parsing...)

对于下载操作,如果您需要下载某些文件

DownloadRequest.init(owner: ObjectIdentifier(self), url: "https://compote.slate.com/images/18ba92e4-e39b-44a3-af3b-88f735703fa7.png?width=1440&rect=1560x1040&offset=0x0", requestType: .get) { progress in
      // progress
  } onDownloadSuccess: { response in
      let data = try? Data(contentsOf: (response?.location!)!) 
  } onFail: { error in
      // error
  }.executeSync()

我们仍在开发这个网络层,新的更新将很快推出。如果您有任何建议,请随时与我联系:[email protected]