Java add Response Headers for all requests

In my application based on API REST, I need to return for all results of all requestes, a custom field in the Response Headers. Now I use this approach:

response().setHeader("custom-field",valuateSender());
return ok(response.addData(body));

In this way, however, I am forced to call the result () method in all my actions, I’m looking for a more general and more intelligent approach.

What you need is a custom ActionCreator.

From the looks of it you are not on Play 2.8.x so you’ll probably need to change the version in the docs.