JAX-RS with HttpSrvletRequest and HttpServletResponse
I have a very special case. There is a Java web server where I can use a plugin to define a RequestHandler that listens to a specific path. For example, I can define that all requests beginning with /api/
are sent to a specific RequestHandler
The RequestHandler shows like:
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; class MyRequestHandler implements RequestHandler { @Override public boolean handlePre(HttpServletRequest request, HttpServletResponse response) { // Do something with request and response try { response.setStatus(200); response.getWriter().write("Hello world"); } catch (IOException e) { e.printStackTrace(); } return true; // Response will send to the client } }
I can handle the Request and the Response but i have no access to the Server-Application itself. Now i want parse the route and forward to the right ResourceController, but doing this by hand is very tedious.
Is there a way to use the Jax-rs routing system with Path and Parameter Annotations? Or is there another uncomplicated way to forward to the right ResourceController?