How to internally call another restapi endpoint in quarkus controller class?

Viewed 32

I need to call another rest api endpoint inside the controller class to provide filtered user list as a result. I can't find a way to call one rest api from another rest api.Controller class

This is my controller class method code:

    @GET
    @Path("/filter")
    @Produces(MediaType.APPLICATION_JSON)
    public Response filterByName(@QueryParam("page") int page, @QueryParam("first_name") String first_name,
            @QueryParam("last_name") String last_name) {
        try{
            String uri = "https://reqres.in/api/users?page="+page;
            //Flux<User1> users = restTemplate.getForObject(uri, User1.class);
            Mono<List<User1>> result = users.filter(user-> user.getFirst_name().equals(first_name) && user.getLast_name().equals(last_name)).collectList();
            return Response.ok(result).build();
            
        }catch(Exception e) {
            
            e.printStackTrace();
            return Response.status(204).build();
        }
    }

My issue got resolved, I used microprofile rest client to create a proxy and called the endpoint from there. Thanks!

1 Answers
Related