@Override
public URI handle(Request request, Response response)
{
if (response.getStatusCode() != HttpStatus.CREATED.code()) {
throw new UnexpectedResponseException(
String.format("Expected response code to be 201 CREATED, but was %s %s", response.getStatusCode(), response.getStatusMessage()),
request,
response);
}
String location = response.getHeader("Location");
if (location == null) {
throw new UnexpectedResponseException("Response does not contain a Location header", request, response);
}
return URI.create(location);
}