I'm implementing a RESTful service using GAE Endpoints in Java. I'm trying to implement token-based authentication method and I wish to add a HTTP response header that contains the token string. However, I'm unable to find documentations on how to change the response header inside a @ApiMethod.
Anybody can shed some light on this? Any help very much appreciated.
From the looks of things, it isn't possible. There is another Stack Overflow Q&A on this question which answered the same way. You can make a Feature Request at the App Engine Public Issue Tracker, of course.
Note: Attempts to use
javax.servlet.Filter to intercept the
ServletResponse, cast it to an
HttpServletResponse and call
.setHeader() on it yielded no success, so it appears there are other layers which are intercepting the response and wrapping up one without any headers added which aren't "meant" to be there, according to Endpoints. I didn't experiment with subclassing
SystemServiceServlet, as the linked Q&A suggested, although that seems fraught with difficulties as well, and undocumented.