title: How to combine HttpServletRequest + @RestController
body: <p>I have developed my current Webapp in Java/Spring MVC. I have exposed my REST services by using the @RestController annotation on a class, looking something like this:</p>
  
  <pre><code>@RestController
  @RequestMapping("/company")
  public class ConcreteCompanyController implements CompanyController {
  
      @RequestMapping(method = RequestMethod.GET)
      @ResponseStatus(value = HttpStatus.OK)
      @Override
      public JsonCompany get(@RequestParam("name") String name) {
         //omitted
      }
  
  }
  </code></pre>
  
  <p>I am also using Google libs that require me to write a class looking kind of like this(taken from googles sample):</p>
  
  <pre><code>public class CalendarAppEngineSample extends AbstractAppEngineAuthorizationCodeServlet {
  
    static final String APP_NAME = "Google Calendar Data API Sample Web Client";
  
    static final String GWT_MODULE_NAME = "calendar";
  
    private static final long serialVersionUID = 1L;
  
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws IOException {
      response.setContentType("text/html");
      response.setCharacterEncoding("UTF-8");
      PrintWriter writer = response.getWriter();
      writer.println("&lt;!doctype html&gt;&lt;html&gt;&lt;head&gt;");
      writer.println("&lt;meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\"&gt;");
      writer.println("&lt;title&gt;" + APP_NAME + "&lt;/title&gt;");
      writer.println(
          "&lt;link type=\"text/css\" rel=\"stylesheet\" href=\"" + GWT_MODULE_NAME + ".css\"&gt;");
      writer.println("&lt;script type=\"text/javascript\" language=\"javascript\" " + "src=\""
          + GWT_MODULE_NAME + "/" + GWT_MODULE_NAME + ".nocache.js\"&gt;&lt;/script&gt;");
      writer.println("&lt;/head&gt;&lt;body&gt;");
      UserService userService = UserServiceFactory.getUserService();
      writer.println("&lt;div class=\"header\"&gt;&lt;b&gt;" + request.getUserPrincipal().getName() + "&lt;/b&gt; | "
          + "&lt;a href=\"" + userService.createLogoutURL(request.getRequestURL().toString())
          + "\"&gt;Log out&lt;/a&gt; | "
          + "&lt;a href=\"http://code.google.com/p/google-api-java-client/source/browse"
          + "/calendar-appengine-sample?repo=samples\"&gt;See source code for "
          + "this sample&lt;/a&gt;&lt;/div&gt;");
      writer.println("&lt;div id=\"main\"/&gt;");
      writer.println("&lt;/body&gt;&lt;/html&gt;");
    }
  
    @Override
    protected String getRedirectUri(HttpServletRequest req) throws ServletException, IOException {
      return Utils.getRedirectUri(req);
    }
  
    @Override
    protected AuthorizationCodeFlow initializeFlow() throws IOException {
      return Utils.newFlow();
    }
  }
  </code></pre>
  
  <p>I don't know how to combine these so that both will be available as rest services. I guess I might have to do something in web.xml, but what? </p>
  
  <p>Edit:</p>
  
  <p>Just to clarify. I have several RestControllers in my project and I do not want to change them. I want to be able to add a file like the CalendarAppEngineSample and make sure that the doGet method is exposed as a rest service. </p>