1 package jalview.javascript.web;
3 import jalview.util.Platform;
5 import java.net.MalformedURLException;
7 import java.net.URISyntaxException;
11 * A JavaScript-only proxy for com.sun.jersey.api.client.WebResource
14 public class WebResource
17 private String endpoint, params = "";
19 public WebResource(String endpoint)
21 this.endpoint = endpoint;
24 public WebResource queryParam(String key, String value)
26 params += (params == "" ? "?" : "&") + key + "="
27 + Platform.encodeURI(value);
35 return new URI(endpoint + params);
36 } catch (URISyntaxException e)
43 public Builder accept(String... encoding)
45 return new Builder(getURI(), encoding);
48 public static class Builder
52 private String[] encoding;
54 public Builder(URI uri, String... encoding)
57 this.encoding = encoding; // application/json
64 * must be ClientResponse
67 public ClientResponse get(Class<?> c)
71 return new ClientResponse(new URL(uri.toString()), encoding);
72 } catch (MalformedURLException e)