Last active
March 24, 2020 11:25
-
-
Save pavlospt/59282a2036252c280932c9419ce39f2a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private val client = HttpClient(OkHttp) { | |
install(JsonFeature) { | |
serializer = GsonSerializer() | |
} | |
install(HttpTimeout) { | |
requestTimeoutMillis = 30_000 | |
} | |
install(Logging) { | |
logger = Logger.DEFAULT | |
level = LogLevel.ALL | |
} | |
engine { | |
config { | |
followRedirects(true) | |
followSslRedirects(true) | |
connectTimeout(30, TimeUnit.SECONDS) | |
readTimeout(30, TimeUnit.SECONDS) | |
writeTimeout(30, TimeUnit.SECONDS) | |
} | |
} | |
} | |
fun Application.module(testing: Boolean = false) { | |
routing { | |
post("/a/route") { | |
call.respond(HttpStatusCodes.OK) | |
val urlResponse = withContext(Dispatchers.IO) { | |
client.post("url") { body = someBodyHere } | |
} | |
val urlResponse2 = withContext(Dispatchers.IO) { | |
client.post("url2") { body = urlResponse.something.from.first.call } | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment