Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

297
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!