Reputation: 151
I have a simple Google cloud endpoint. How can I access the context? I'm looking for something similar to getServletContext()
from HttpServlet
.
@Api
public FooEndpoint {
@ApiMehod
public String[] getFiles() {
// TODO: return files in WEB-INF/data
}
}
Upvotes: 2
Views: 286
Reputation: 991
The servlet context is an injected type. Just include it as a method argument to an endpoint method and the server will fill it in for you. E.g.
@Api
public FooEndpoint {
@ApiMethod
public String[] getFiles(ServletContext context) {
// TODO: return files in WEB-INF/data
}
}
You don't need to annotate the argument, and it won't appear in the method stub in the generated client library.
Upvotes: 3