I am trying to implement RequestDispatcher using the dropwizard, which should look at the Entity in the body for messages and compute certain statistics.
so I implemented ResourceMethodDispatchAdapterand ResourceMethodDispatchProvider, and I can successfully insert and call my RequestDispatcher,
private static class InspectRequestDispatcher implements RequestDispatcher {
private final RequestDispatcher dispatcher;
private InspectRequestDispatcher(RequestDispatcher dispatcher) {
this.dispatcher = dispatcher;
}
@Override
public void dispatch(final Object resource, final HttpContext context) {
final Saying day = context.getRequest().getEntity(Saying.class);
dispatcher.dispatch(resource, context);
}
}
The above code throws an exception, since I already read the body (which is understandable), I could reset the stream, but then I will pay a fine for reading the body twice.
Is it possible to intercept a method call AFTER parameters have been entered? for some reason to plan this interceptor last?
using dropwizard version 7
source
share