Mario Andhika
12/02/2024, 4:11 AMhref(MyResourceDTO())
. Is there a way to do this in Ktor Client also? I want to avoid hardcoding the paths.hfhbd
12/02/2024, 6:48 AMMario Andhika
12/02/2024, 7:42 AM@Resource("login")
class LoginRequest
but href(LoginRequest())
is giving me error None of the following candidates is applicable:
Mario Andhika
12/02/2024, 8:03 AMNone of the following candidates is applicable:
fun <reified T : Any> HttpClient.href(resource: T): String
fun <reified T : Any> HttpClient.href(resource: T, urlBuilder: URLBuilder): Unit
Mario Andhika
12/02/2024, 8:03 AMimport io.ktor.client.plugins.resources.href
on Ktor Client 3.0.1Aleksei Tirman [JB]
12/02/2024, 10:53 AMhref
function from the io.ktor.resources
package and pass the resource format as the first argument:
import io.ktor.resources.*
import io.ktor.resources.serialization.ResourcesFormat
val str = href(ResourcesFormat(), LoginRequest())
println(str)
Mario Andhika
12/03/2024, 2:46 AM