ResourceHandlerFunction returns EntityResponse

The ResourceHandlerFunction now returns an `EntityResponse<Resource>`
(instead of a `ServerResponse`), so that filters can inspect/change the
returned Resource.
This commit is contained in:
Arjen Poutsma
2017-05-10 15:07:54 +02:00
parent 8db4b2f7ed
commit ad9cf99420
2 changed files with 14 additions and 21 deletions

View File

@@ -56,12 +56,12 @@ class ResourceHandlerFunction implements HandlerFunction<ServerResponse> {
public Mono<ServerResponse> handle(ServerRequest request) {
switch (request.method()) {
case GET:
return ServerResponse.ok()
.body(BodyInserters.fromResource(this.resource));
return EntityResponse.fromObject(this.resource).build()
.map(response -> response);
case HEAD:
Resource headResource = new HeadMethodResource(this.resource);
return ServerResponse.ok()
.body(BodyInserters.fromResource(headResource));
return EntityResponse.fromObject(headResource).build()
.map(response -> response);
case OPTIONS:
return ServerResponse.ok()
.allow(SUPPORTED_METHODS)