Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

296
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda