Skip to content

Instantly share code, notes, and snippets.

@stain
Created March 27, 2013 16:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stain/5255891 to your computer and use it in GitHub Desktop.
Save stain/5255891 to your computer and use it in GitHub Desktop.
private static final String HAS_PROVENANCE = "http://www.w3.org/ns/prov#has_provenance";
@GET
@Path("hello/{name}")
@Produces("text/plain")
public Response hello(@PathParam("name") String name, @Context UriInfo ui) {
// TODO: Could have used Link.fromResourceMethod instead,
// but it seems to return wrong URI in current CXF
URI provUri = ui.getBaseUriBuilder().path(getClass(), "helloProvenance").build(name);
Link provLink = Link.fromUri(provUri).rel(HAS_PROVENANCE).build();
String greeting = "Hello, " + name + "\n";
ResponseBuilder responseBuilder = Response.ok().entity(greeting);
return responseBuilder.header(HttpHeaders.LINK, provLink).build();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment