Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

272
Vistas
KTor URLBuilder encodedPath with dynamic path

I'm trying to build a network module for Multiplatform project with ktor. My code for GET request is something like this:

val result = httpClient.get<HttpResponse> {
                    url {
                        protocol = baseProtocol
                        host = baseUrl
                        encodedPath = urlPath

                    }
}

In some point my path contain a user id like this /users/{user_id}. I can do a search and replace in string and replace this user_id with actual value, BUT is there any other way to do this? any ktor specific way.

For example with Retrofit we have this:

@GET("users/{user_id}/")
SomeData getUserData(@Path("user_id") String userId);

EDIT: adding more code

val result = httpClient.get<HttpResponse> {
                    url {
                        protocol = baseProtocol
                        host = baseUrl

                        var requestPath = request.requestPath.value
                        request.path?.forEach {
                            requestPath = requestPath.replace(it.first, it.second)
                        }
                        encodedPath = requestPath

                        if (request.parameters != null) {
                            parameters.appendAll(getParametersFromList(request.parameters))
                        }
                    }

the request.path?.forEach { requestPath = requestPath.replace(it.first, it.second)} replacing any runtime path value.

over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda