Hi, why default request builder lambda is not `sus...
# ktor
b
Hi, why default request builder lambda is not
suspend
in the Default Request plugin? I want to add some header to the request from a local storage, and the query to that storage is based on coroutines. Thought Ktor as the superior client would handle that easily. To my suprise this won't compile because the builder is missing the
suspend
modifier. Why is that?
Copy code
install(DefaultRequest) {
    header("some key", someRepo.getValue())
}
Where
someRepo.getValue()
is suspend function. Based on implementation of Default Request plugin I've managed to create such a bypass for that when building the HttpClient:
Copy code
.apply {
    requestPipeline.intercept(HttpRequestPipeline.Before) {
        header("some key", someRepo.getValue())
    }
}
for now I've created a ticket for that, and maybe will even try to contribute it myself https://youtrack.jetbrains.com/issue/KTOR-8775/Make-Default-Request-builder-suspend