I am using a Filter to detect some api operations and do some validation work. what is the normal way to get which api operation is currently called using HttpServletRequest? Right now, I am doing something like this:
if (httpRequest.getMethod().equalsIgnoreCase("GET")
&& httpRequest.getRequestURI().toLowerCase().contains("expectedOperatinName"))
to check if it is the expected api call. However,
Please help. Thanks
Did you look into the UriInfo interface that has methods on which resource matched the passed in request? You can access the UriInfo from the request like this:
containerRequestContext.getUriInfo()
I think you can easily find out which operation was honored using getMatchedResources() on the UriInfo. If you are trying to find the exact method that honored the request, look into UriRoutingContext class.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.