Created
March 27, 2013 16:45
-
-
Save stain/5255891 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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