I am creating a Google Appengine endpoint api. In one of the endpoint methods, I need to detect the base url. How might I do that in Java?
As per the documentation, you can pass an injected type into your API Methods. For e.g. you could inject the HTTPServletRequest object into your API Method. https://developers.google.com/appengine/docs/java/endpoints/paramreturn_types#injected_types
Once you have the Request object, you can then get the base url as needed. For e.g.
StringBuffer url = req.getRequestURL();
String uri = req.getRequestURI();
String ctx = req.getContextPath();
String base = url.substring(0, url.length() - uri.length() + ctx.length()) + "/";