/** * A thin wrapper around the HTTP methods. */ public Response api(Request request) throws IOException { try { if (request.getMethod() == null) { throw new IOException("We only support GET, PUT, PATCH, POST and DELETE."); } switch (request.getMethod()) { case GET: return get(request); case POST: return post(request); case PUT: return put(request); case PATCH: return patch(request); case DELETE: return delete(request); default: throw new IOException("We only support GET, PUT, PATCH, POST and DELETE."); } } catch (IOException ex) { throw ex; } catch (URISyntaxException ex) { StringWriter errors = new StringWriter(); ex.printStackTrace(new PrintWriter(errors)); throw new IOException(errors.toString()); } }