In case of an exception in my Java REST application I would like to log various information on causing HTTP request.
I can obtain the URI of the request and the HTTP headers via context injection
@Context
private UriInfo uriInfo;
@Context
private HttpHeaders headers;
But how can I obtain the HTTP method (GET, PUT, ...)?
I use Jersey. Don't know if this applies for you but ... :
import javax.servlet.http.HttpServletRequest;
@Context final HttpServletRequest request
The Request
class has the method getMethod()
. It returns the used HTTP method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With