Revert "Infer HTTP 404 from empty Optional/Publisher types"

This reverts commit 7e91733502.
This commit is contained in:
Brian Clozel
2018-08-15 15:15:35 +02:00
parent 1b54d2119d
commit f2506ca7a1
6 changed files with 86 additions and 155 deletions

View File

@@ -1749,10 +1749,14 @@ controller. The following code snippet shows the usage:
[TIP]
====
<<<<<<< HEAD
Unlike the Servlet API "request parameter" concept that conflates query parameters, form
=======
Unlike the Servlet API "request paramater" concept that conflate query parameters, form
>>>>>>> parent of 7e91733502... Infer HTTP 404 from empty Optional/Publisher types
data, and multiparts into one, in WebFlux each is accessed individually through the
`ServerWebExchange`. While `@RequestParam` binds to query parameters only, you can
use data binding to apply query parameters, form data, and multiparts to a
use data binding to apply query paramerters, form data, and multiparts to a
<<webflux-ann-modelattrib-method-args,command object>>.
====
@@ -2275,22 +2279,6 @@ on a container object that specifies request headers and body. Below is an examp
}
----
As is the case for many return values, `ResponseEntity` can be wrapped by a reactive type
such as `Mono`. In case of a `Mono<ResponseEntity>` return type, an empty `Mono` will be
automatically converted to a `ResponseEntity` with an empty body and an HTTP 404 status,
so you don't need to chain your `Mono` with a `switchIfEmpty` / `defaultIfEmpty` for
simple HTTP 404 responses. Here's an example of this:
[source,java,indent=0]
[subs="verbatim,quotes"]
----
@GetMapping("/user")
public Mono<ResponseEntity<User>> fetchUser() {
Mono<User> user = //...
return user.map(ResponseEntity::ok);
}
----
[[webflux-ann-jackson]]
==== Jackson JSON

View File

@@ -1816,7 +1816,7 @@ supported for all return values, see below for more details.
| The return value is converted through ``HttpMessageConverter``s and written to the
response. See <<mvc-ann-responsebody>>.
| `HttpEntity<B>`, `ResponseEntity<B>`, `Optional<HttpEntity<B>>`, `Optional<ResponseEntity<B>>`
| `HttpEntity<B>`, `ResponseEntity<B>`
| The return value specifies the full response including HTTP headers and body be converted
through ``HttpMessageConverter``s and written to the response.
See <<mvc-ann-responseentity>>.
@@ -2660,21 +2660,6 @@ on a container object that specifies request headers and body. Below is an examp
}
----
In case of a `java.util.Optional<ResponseEntity>` return type, the `Optional.empty()`
case will be automatically converted to a `ResponseEntity` with an empty body and an HTTP
404 status, so you don't need to chain your optional with an `orElse` / `orElseGet` for
simple HTTP 404 responses. Here's an example of this:
[source,java,indent=0]
[subs="verbatim,quotes"]
----
@GetMapping("/user")
public Optional<ResponseEntity<User>> fetchUser() {
Optional<User> user = //...
return user.map(ResponseEntity::ok);
}
----
[[mvc-ann-jackson]]
==== Jackson JSON