-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Andrej Završnik edited this page May 9, 2017
·
17 revisions
This is a small library that enables triggering of additional events to be executed when a RestEasy REST API is called. It is intended to be used in combination with Guice dependency injection.
It supports:
- synchronous and asynchronous event execution
- Guice injected events
- triggering on specific HTTP response codes
- triggering on exceptions
Execution of events takes place in the moment the REST call is completed, the event itself receives the response entity and response HTTP code when invoked.
NOTE:
If a REST API is excessively called the event triggering can fill up the underlying thread pool. One should consider where events are appropriate, especially on publicly available REST API's.
An attack on a certain API with a RestEvent can significantly impact the REST performance.
<dependency>
<groupId>com.zandero</groupId>
<artifactId>rest</artifactId>
<version>1.2</version>
</dependency>
Either bind AsyncRestFilterModule or manually bind following:
bind(RestExceptionMapper.class); // mandatory for exception event filtering
bind(RestRequestEventFilter.class); // optional in case request duration log should be added
bind(RestResponseEventFilter.class); // mandatory for event filtering
bind(RestEventThreadPool.class).to(RestEventThreadPoolImpl.class); // optional for asynchronous event execution, one can bind his own thread pool if desired