swifter
swifter copied to clipboard
Response Body for 201 and 500
Is there currently not a way to respond with JSON for 201 & 500 responses? I'm mocking a Rails server that does respond to those statuses with content.
404 as well.
Any update on this?
would be great to have 207(multiStatus) status code response with JSON, too.
I had to create my own response code with a custom body. This might be of help
extension HttpResponse {
static func NotFoundResponseWithBody(body: AnyObject) -> HttpResponse {
let data = try! JSONSerialization.data(withJSONObject: body)
return HttpResponse.raw(404, "Not found", nil, { (writer) in
try writer.write(data)
})
}
}