@Path("tasks/{title}")
public Response createTask(@Context UriInfo info, @Context SecurityContext context,
@PathParam("title") @DefaultValue("task") String taskTitle) {
User user = getUser(context);
Task task = new Task(taskTitle);
taskDao.createTask(user, task);
// Construct the URI for the newly created resource and put in into the Location header of the response
// (assumes that there is only one occurrence of the task title in the request)
String rawPath = info.getAbsolutePath().getRawPath().replace(task.getTitle(), task.getId().toString());
UriBuilder uriBuilder = info.getAbsolutePathBuilder().replacePath(rawPath);
URI uri = uriBuilder.build();
return Response.created(uri).build();
}