Skip to content

Commit a172cbc

Browse files
committed
Add return types description
1 parent d183927 commit a172cbc

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

framework-docs/modules/ROOT/pages/web/webflux/controller/ann-methods/return-types.adoc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,7 @@ Reactor provides a dedicated operator for that, `Flux#collectList()`.
8989
downloads or proxying data.
9090

9191
| `Resource`
92-
| Return a single resource that is written to the response using `ResourceHttpMessageWriter`.
93-
94-
Notice, this writer overrides your response's `Content-Type` header, make sure you're intending to do so.
92+
| Return a single resource that is written to the response using xref:web/webflux/reactive-spring.adoc#webflux-codecs-resource[ResourceHttpMessageWriter].
9593

9694
| Other return values
9795
| If a return value remains unresolved in any other way, it is treated as a model

framework-docs/modules/ROOT/pages/web/webflux/reactive-spring.adoc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,12 @@ and from higher level objects, or unless they choose to create custom codecs. Fo
611611
cases please review the information in xref:core/databuffer-codec.adoc[Data Buffers and Codecs],
612612
especially the section on xref:core/databuffer-codec.adoc#databuffers-using[Using DataBuffer].
613613

614+
[[webflux-codecs-resource]]
615+
=== `Resource`
616+
617+
`Resource` is a general abstraction for file-like resources in Spring. WebFlux applications can use the `ResourceHttpMessageReader` and `ResourceHttpMessageWriter` to read and write `Resource` instances to and from HTTP requests and responses.
618+
619+
Notice, the `ResourceHttpMessageWriter` automatically detects the media type by the filename of the `Resource` and uses it to override your response's `Content-Type` header. If the detection fails, `application/octet-stream` is used as a fallback. Don't return `Resource` type if you want to control the media type of the response.
614620

615621
[[webflux-logging]]
616622
== Logging

framework-docs/modules/ROOT/pages/web/webmvc/message-converters.adoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,9 @@ content type. This requires the `com.google.protobuf:protobuf-java` dependency.
8383
| An `HttpMessageConverter` implementation that can read and write JSON documents to and from Protobuf messages.
8484
This requires the `com.google.protobuf:protobuf-java-util` dependency.
8585

86+
| `ResourceHttpMessageConverter`
87+
| An `HttpMessageConverter` implementation that can read and write `org.springframework.core.io.Resource` instances from the HTTP request and response.
88+
89+
Notice, the `ResourceHttpMessageWriter` automatically detects the media type by the filename of the `Resource` and uses it to override your response's `Content-Type` header. If the detection fails, `application/octet-stream` is used as a fallback. Don't return `Resource` type if you want to control the media type of the response.
90+
8691
|===

framework-docs/modules/ROOT/pages/web/webmvc/mvc-controller/ann-methods/return-types.adoc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,7 @@ supported for all return values.
9696
xref:web/webmvc/mvc-ann-async.adoc#mvc-ann-async-reactive-types[Reactive Types].
9797

9898
| `Resource`
99-
| Return a single resource that is written to the response using
100-
`ResourceHttpMessageConverter` implementations.
101-
102-
Notice, this writer overrides your response's `Content-Type` header, make sure you're intending to do so.
99+
| Return a single resource that is written to the response using `ResourceHttpMessageConverter` implementations.
103100

104101
| Other return values
105102
| If a return value remains unresolved in any other way, it is treated as a model

0 commit comments

Comments
 (0)