https://kotlinlang.org logo
#ktor
Title
# ktor
p

Pablo

04/14/2021, 6:20 PM
Is there any way to do a
get
inside a
Copy code
return HttpClient(OkHttp) {
  //For instance if I want to update a refreshToken
}
d

Dominaezzz

04/14/2021, 6:26 PM
It's definitely possible if you implement your own feature. Copy the code from
OAuthFeature
and modify it pass the client to the lambdas.
p

Pablo

04/14/2021, 6:43 PM
But the thing is how do I do a
get
in the lambda? If to do so I need an HttpClient, right?
d

Dominaezzz

04/14/2021, 6:43 PM
You'll have the
HttpClient
when installing the feature.
p

Pablo

04/14/2021, 6:45 PM
How do I get reference of HttpClient? For instance if I have a service that via parameter receives an httpclient how do I call this? Service(httpClient:HttpClient) inside the feature?
j

Joost Klitsie

04/15/2021, 7:23 AM
I misread your question at first, but you will probably be looking for features. Usually you cannot use an object while configuring it, exactly like here.
Or you construct an http client that can handle authentication
and a second one to handle any other api calls
but yeah then you will have twice the resources in use
otherwise, perhaps have a look here: https://github.com/ktorio/ktor/issues/1967
3 Views