Could someone help me find an example of a ktor cl...
# ktor
j
Could someone help me find an example of a ktor client that interacts with a versioned rest api?
t
Do you need nested routes?
j
I think that's a server side thing, I'm looking for the client side equivalent I think 🤔
t
For React? Which framework?
j
Just a hand written ktor client
I probably should just wrap ktor http client and have the path change the version of my api based on some kind of session
t
No SPA?
j
The kmp js target will be a react component library for the main TS SPA
a
You can use URLBuilder to create various URLs reusing common components. Here is an example:
Copy code
val v1 = listOf("v1")
val users = v1 + listOf("users")
val baseUrl = URLBuilder("<https://mywebsite.com/>")

println(baseUrl.build())
println(URLBuilder(baseUrl).apply { path(v1) }.build())
println(URLBuilder(baseUrl).apply { path(users) }.build())
j
ah nice, so I’ll just have a handful of builders around, one per version perhaps? thanks, I’ll look into this more
a
Maybe, do whatever more convenient for you.