siesta-swift

How to decorate Siesta request with an asynchronous task

為{幸葍}努か 提交于 2021-02-19 08:59:45
问题 What is the correct way to alter a Request performing an asynchronous task before the Request happens? So any request Rn need to become transparently Tn then Rn. A little of background here : The Task is a 3rd party SDK that dispatch a Token I need to use as Header for the original request. My idea is to decorate the Rn, but in doing this I need to convert my Tn task into a Siesta Request I can chain then. So I wrapped the Asynchronous Task and chained to my original request. Thus any Rn will

ios swift siesta ResourceObserver resourceRequestProgress never called

。_饼干妹妹 提交于 2019-12-23 02:34:21
问题 I am using Siesta for REST calls and I am trying to create a simple ResourceObserver to display a SVProgressHUD. open class SVProgressHUDResourceObserver: ResourceObserver { static let sharedInstance = SVProgressHUDResourceObserver() // Show/Hide SVProgressHUD public func resourceRequestProgress(for resource: Resource, progress: Double) { print("SVProgressHUDResourceObserver resourceRequestProgress - progress=\(progress)") if progress == 1 { print("SVProgressHUD.dismiss()") SVProgressHUD

Configure request method for a Siesta resource

隐身守侯 提交于 2019-12-09 07:59:09
问题 I have this api where the login works via post while most other requests work with get. Now I am using siesta to define the login url as a resource. func login(username: String, password: String) -> Resource { return self.resource("login").withParam("username", username).withParam("password", password); } The problem is that when I use .loadIfNeeded() on this resource it will do a get request, but that won't work because it needs to be a post request. Now I know of the existence of

Siesta iOS GET request with url parameters

扶醉桌前 提交于 2019-12-06 06:14:30
问题 Is there a way to make a GET request in Siesta, while providing parameter, like http://example.com/api/list.json?myparam=1? I tried with myAPI.resource("list.json?myparam=1") but the question mark gets escaped. Then I tried with myAPI.resource("list.json").request(.GET, urlEncoded:["myparam": "1"]) but it always fails with "The network connection was lost.", but all other requests succeed, so the message is wrong. 回答1: You are looking for withParam: myAPI.resource("list.json").withParam(

Siesta iOS GET request with url parameters

為{幸葍}努か 提交于 2019-12-04 12:04:18
Is there a way to make a GET request in Siesta, while providing parameter, like http://example.com/api/list.json?myparam=1 ? I tried with myAPI.resource("list.json?myparam=1") but the question mark gets escaped. Then I tried with myAPI.resource("list.json").request(.GET, urlEncoded:["myparam": "1"]) but it always fails with "The network connection was lost.", but all other requests succeed, so the message is wrong. You are looking for withParam : myAPI.resource("list.json").withParam("myparam", "1") The Service.resource(_:) method you are trying to use in your first example specifically avoids

Configure request method for a Siesta resource

妖精的绣舞 提交于 2019-12-03 09:15:52
I have this api where the login works via post while most other requests work with get. Now I am using siesta to define the login url as a resource. func login(username: String, password: String) -> Resource { return self.resource("login").withParam("username", username).withParam("password", password); } The problem is that when I use .loadIfNeeded() on this resource it will do a get request, but that won't work because it needs to be a post request. Now I know of the existence of .decorateRequests, but I'm unsure how to use that to make my login resource use post as request method. Thanks in

Swift Siesta access response raw data

帅比萌擦擦* 提交于 2019-12-02 19:59:25
问题 I've in my API a method that return a content of PDF file. How can I access the raw data of response in success callback? 回答1: All Siesta responses start out as raw data (in the form of the Foundation type Data ), then run through the transformer pipeline. The default transformer pipeline parses JSON, text, and images based on the Content-type header sent by the server. That list doesn’t include PDF, so if your server is sending a content type of application/pdf (or anything that isn’t a JSON

Swift Siesta access response raw data

China☆狼群 提交于 2019-12-02 11:17:29
I've in my API a method that return a content of PDF file. How can I access the raw data of response in success callback? All Siesta responses start out as raw data (in the form of the Foundation type Data ), then run through the transformer pipeline . The default transformer pipeline parses JSON, text, and images based on the Content-type header sent by the server. That list doesn’t include PDF, so if your server is sending a content type of application/pdf (or anything that isn’t a JSON, text, or image content type), the response will still be raw Data at the end of the pipeline: request