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

Jérôme Gully

11/27/2020, 2:47 PM
Hi, I use the Ktor http client in a MP project, I have an api url with a custom part like
"users/{name}/commits"
, is there something in Ktor to handle this ? For the moment I use `"users/{name}/commits".replace("{name}", "Jérôme")`🙃 Retrofit handle it like this :
Copy code
@GET("users/{name}/commits")
Call<List<Commit>> getCommitsByName(@Path("name") String name);
m

mmaillot

11/27/2020, 2:51 PM
You can use string template : “users/$name/commits” where $name is the variable containing Jérôme.
j

Jérôme Gully

11/27/2020, 4:45 PM
Thanks, yep it's nice but it's working only if you have the path IN the method, you can't refer to an extern property to reuse it
m

mmaillot

11/27/2020, 5:03 PM
It’s the same for Retrofit. But I see what you want but I don’t have solution. Perhaps an other lib...
8 Views