How to add "last modified" response header to REST API

For anyone viewing this later, please see How to add "last modified date" and "publish date" to Resourse API response for the solution.