Assert we return Location header with 201 CREATED

Add an assertion to the most popular way of turning the response object
into the actual http response. As it stands all places we return
`201 CREATED` we return the `Location` header. This will help to keep it
that way, though it won't catch all uses.

Followup to #19509
This commit is contained in:
Nik Everett 2016-07-27 17:39:19 -04:00
parent 2e7336dc10
commit e04f06258f
1 changed files with 4 additions and 2 deletions

View File

@ -37,8 +37,10 @@ public class RestStatusToXContentListener<Response extends StatusToXContent> ext
* Build an instance that doesn't support responses with the status {@code 201 CREATED}.
*/
public RestStatusToXContentListener(RestChannel channel) {
// TODO switch this to throwing an exception?
this(channel, r -> null);
this(channel, r -> {
assert false: "Returned a 201 CREATED but not set up to support a Location header";
return null;
});
}
/**