After a discussion with qmx and Bruno there was a suggestion to have some sort for filter pattern for AeroGear-Controller. This gist describes a suggestion in hope to "buy" some time to implement this.
CDI has the concept of decorators and interceptors which might be a nice fit for our use case. The idea would be to enable us to specify either/both interceptors/decorators to implement things like Security, Error handling, CORS support etc.
As an example, we have done some prototyping and the following section describes how decorators could be used. There are two cases that we have identified so far:
- The decorator only needs to inspect/interact with HttpServletRequest and HttpServletResponse
- The decorator need access to the Route to perform an action before or after invoking the target Route