code: public static URI getUri(UriInfo uriInfo,
                               HttpServletRequest req,
                               String path) {
          String suffix = "";
          if (req.getRequestURI().endsWith(".json")) {
              suffix = ".json";
          } else if (req.getRequestURI().endsWith(".xml")) {
              suffix = ".xml";
          }
          return URI.create(uriInfo.getBaseUri() + "/" + path + suffix);
      }
docs: Gets a full URI for the given path, based on the request URI.