title: Obtain the request in Resteasy JAX-RS method
body: <p>I have a Jax-Rs service that I run with Resteasy, and in the implementation of the methods I want to access the request data. I know of the existence of the <a href="https://jersey.java.net/documentation/latest/jaxrs-resources.html#d0e2486" rel="nofollow">@Context</a> annotation but this requires me to modify the service interface which is not practical (or even possible with Java Jax-Rs clients) that use the same interface for client proxy creation.</p>
  
  <p>So to make it cleaner, I have this interface which I can't modify.</p>
  
  <pre><code>@POST
  @Path("/ping")
  @Consumes({ javax.ws.rs.core.MediaType.APPLICATION_JSON, javax.ws.rs.core.MediaType.APPLICATION_XML })
  @Produces({ javax.ws.rs.core.MediaType.APPLICATION_JSON, javax.ws.rs.core.MediaType.APPLICATION_XML })
  public String ping();
  </code></pre>
  
  <p>And in the implementation I want to do something like this (kind of pseudo code)</p>
  
  <pre><code>@Override
  public String ping() {
      String client = SomeContextAccessor.getRequest().getRemoteAddress());
  
      //Use the request info
  
      return "a nice string";
  }
  </code></pre>
  
  <p>I know there are some classes with static methods that allow me to do this but can't find info about those.</p>