0

I have a Restful post method that answers to any client. when called, it runs a standard query and returns the result to the caller-- whoever that might be.

i'm looking to log the caller URL in this method. how to get the caller URL?

following is the method in a nutshell (error/edge conditions removed):

@POST  
public static Response makeQuery() { 
        return Response.ok(query()).build();  // invoke query() and hand in the result 
}
  • duplicate http://stackoverflow.com/questions/5118752/how-do-i-access-the-http-request ? – numX Sep 26 '16 at 20:44

1 Answers1

0

You can inject UriInfo object and inspect the request URL including params.

@POST  
public static Response makeQuery( @Context UriInfo uriInfo) { 
        System.out.println(uriInfo.getAbsolutePath());
        return Response.ok(query()).build();  // invoke query() and hand in the result 
}
uday
  • 129
  • 6