Repeating http request until response status is equal 504

I try some case:

  • if my http response is 200 then OK, go to next step of chain
  • if my http response i 504 repeat http request until response is not 504
  • If my http response is not 200 and is not 504 then “exitHereIfFailed”

What is the best solution of my case. I have only one idea - something like following (pseudo-code):

def myRequest:ChainBuilder = … .check(, 504), status.saveAs(“statusCode”)).exitHereIfFailed

myRequest.asLongAs(session => session(“statusCode”) != 200) { myRequest }

But this is very ugly solution. Any better idea?

No idea why you call this ugly: this is the proper way.

Thanks for response. I encapsulate this code implicit class and now it looks ok. I do smh like that:

implicit class RichChainBuilder(b: ChainBuilder) {
def execAsLongAsNoTimeout(builder: ActionBuilder) = {
b.exec(builder).asLongAs(session => session(statusCodeKey).as[Int] == 504) {

And now instead call exec in my code i call execAsLongAsNoTimeout

W dniu środa, 12 sierpnia 2015 17:31:40 UTC+2 użytkownik Radosław Twardy napisał: