Skip to content

Instantly share code, notes, and snippets.

@lynas
Created July 16, 2017 14:53
Show Gist options
  • Save lynas/c9e487378f1fcc60aa83ca370bb9acef to your computer and use it in GitHub Desktop.
Save lynas/c9e487378f1fcc60aa83ca370bb9acef to your computer and use it in GitHub Desktop.
public Response postPatchDelete(HttpServletRequest request, String url, String method, Object object) {
Client client = ClientBuilder.newClient();
try {
return client
.target(REST_URL_BASE + url)
.request()
.header(X_AUTH_TOKEN, getToken(request))
.build(
method,
Entity.entity(
mapper.writeValueAsString(object),
MediaType.APPLICATION_JSON))
.invoke();
} catch (JsonProcessingException e) {
e.printStackTrace();
return null;
}
}
public Response get(HttpServletRequest request,String url){
System.out.println(REST_URL_BASE+url);
Client client = ClientBuilder.newClient();
return client.
target(REST_URL_BASE + url)
.request()
.header(X_AUTH_TOKEN, getToken(request))
.get();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment