Posts

Showing posts with the label siesta-swift

Mark successful siesta response as error

Mark successful siesta response as error I'm working with a really strange (and nasty) API that I have no control over, and unfortunately when an invalid request is made, instead of responding with a 4xx status, it responds with a 200 status instead. With this response, it also changes the response body from the usual XML response to plain text, but does not change the content type header. You can imagine how annoying this is! I've got Siesta working with the API and the fact that it is no actually RESTful in the slightest, but I'm unsure how to get the next part working - handling the unsuccessful requests. How do I go about transforming a technically valid and successful 200 response, into an error response? Right now I have the following setup: configure("/endpoint") { $0.mutateRequests { req in ... perform some mutation to request ... } $0.pipeline[.parsing].add(self.XMLTransformer) } configureTransformer("/endpoint") { ($0.content as API...