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

294
Vistas
How do I use okhttp in the spring cloud ribbon

The getting started of the spring cloud ribbon is very easy and simple, and it is using the rest template to communicate with backend servers.

But in our project we are more like to use okhttp to do the http request, does anyone can help?

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You can take a look at the spring-cloud-square project which supplies integration with Square's OkHttpClient and Netflix Ribbon via Spring Cloud Netflix, on the Github. Let's see a test method in the OkHttpRibbonInterceptorTests.java class

@Test
@SneakyThrows
public void httpClientWorks() {
    Request request = new Request.Builder()
            // here you use a service id, or virtual hostname
            // rather than an actual host:port, ribbon will
            // resolve it
            .url("http://" + SERVICE_ID + "/hello")
            .build();
    Response response = builder.build().newCall(request).execute();
    Hello hello = new ObjectMapper().readValue(response.body().byteStream(), Hello.class);
    assertThat("response was wrong", hello.getValue(), is(equalTo("hello okhttp")));
}
about 4 years ago · Santiago Trujillo Denunciar
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