
RetryAfter.pudu
Pudu20 lines704 B
1/** @Domain.RetryAfter.Module — how long a server asked the client to wait */2module PuduLangHttpClient.Domain.RetryAfter34import Std.Math as Math5import PuduLangHttpClient.Domain.Date as Date678910export fn delay(value: Str, now: Int) -> Option[Int] {11 let trimmed = value.trim()12 match trimmed.toInt() {13 case Some(seconds) => if seconds < 0 { None } else { Some(seconds * 1000) }14 case None => {15 let at = Date.parse(trimmed) ?16 Some(Math.max(at - now, 0))17 }18 }19}20