Skip to content

Commit e0b5deb

Browse files
committed
Sync documentation of main branch
1 parent 4c40a2c commit e0b5deb

File tree

5 files changed

+71
-3
lines changed

5 files changed

+71
-3
lines changed

_generated-doc/main/config/quarkus-all-config.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79368,7 +79368,7 @@ Environment variable: `+++QUARKUS_DATASOURCE_REACTIVE_CACHE_PREPARED_STATEMENTS+
7936879368
endif::add-copy-button-to-env-var[]
7936979369
--
7937079370
|boolean
79371-
|`+++false+++`
79371+
|`+++true for PostgreSQL/MySQL/MariaDB/Db2, false otherwise+++`
7937279372

7937379373
a| [[quarkus-reactive-datasource_quarkus-datasource-reactive-url]] [.property-path]##link:#quarkus-reactive-datasource_quarkus-datasource-reactive-url[`quarkus.datasource.reactive.url`]##
7937479374
ifdef::add-copy-button-to-config-props[]

_generated-doc/main/config/quarkus-reactive-datasource.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Environment variable: `+++QUARKUS_DATASOURCE_REACTIVE_CACHE_PREPARED_STATEMENTS+
5757
endif::add-copy-button-to-env-var[]
5858
--
5959
|boolean
60-
|`+++false+++`
60+
|`+++true for PostgreSQL/MySQL/MariaDB/Db2, false otherwise+++`
6161

6262
a| [[quarkus-reactive-datasource_quarkus-datasource-reactive-url]] [.property-path]##link:#quarkus-reactive-datasource_quarkus-datasource-reactive-url[`quarkus.datasource.reactive.url`]##
6363
ifdef::add-copy-button-to-config-props[]

_generated-doc/main/config/quarkus-reactive-datasource_quarkus.datasource.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Environment variable: `+++QUARKUS_DATASOURCE_REACTIVE_CACHE_PREPARED_STATEMENTS+
5757
endif::add-copy-button-to-env-var[]
5858
--
5959
|boolean
60-
|`+++false+++`
60+
|`+++true for PostgreSQL/MySQL/MariaDB/Db2, false otherwise+++`
6161

6262
a| [[quarkus-reactive-datasource_quarkus-datasource-reactive-url]] [.property-path]##link:#quarkus-reactive-datasource_quarkus-datasource-reactive-url[`quarkus.datasource.reactive.url`]##
6363
ifdef::add-copy-button-to-config-props[]

_versions/main/guides/rest.adoc

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,34 @@ public class Endpoint {
778778
NOTE: You can also use the Jakarta REST type link:{jaxrsapi}/jakarta/ws/rs/core/Response.html[`Response`] but it is
779779
not strongly typed to your entity.
780780

781+
==== Responding with files
782+
783+
When a file needs to be returned, the following code ensures that Quarkus properly streams the file contents to the client.
784+
785+
[source,java]
786+
----
787+
package org.acme.rest;
788+
789+
import jakarta.ws.rs.GET;
790+
import jakarta.ws.rs.Path;
791+
import org.jboss.resteasy.reactive.RestResponse;
792+
import org.jboss.resteasy.reactive.RestResponse.ResponseBuilder;
793+
794+
@Path("")
795+
public class Endpoint {
796+
797+
@Path("file")
798+
@GET
799+
public RestResponse<java.nio.file.Path> largePathRestResponse() throws IOException {
800+
java.nio.file.Path path = ...
801+
802+
return RestResponse.ResponseBuilder.ok(path)
803+
.header(HttpHeaders.CONTENT_DISPOSITION, "some-file-name")
804+
.build();
805+
}
806+
}
807+
----
808+
781809
==== Using annotations
782810

783811
Alternatively, if you only need to set the status code and / or HTTP headers with static values, you can use `@org.jboss.resteasy.reactive.ResponseStatus` and /or `ResponseHeader` respectively.

_versions/main/guides/spring-web.adoc

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,46 @@ The following parameter types are supported, in arbitrary order:
469469

470470
Other parameter types mentioned in the Spring `https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/bind/annotation/ExceptionHandler.html[ExceptionHandler javadoc]` are not supported.
471471

472+
==== Using `HttpServerRequest` and `HttpServerResponse` in Spring Web-style exception handlers
473+
474+
When using the Quarkus Spring Web compatibility layer on top of the reactive stack (`quarkus-rest-jackson`),
475+
you cannot inject servlet-based request and response types such as `jakarta.servlet.http.HttpServletRequest` or `jakarta.servlet.http.HttpServletResponse`.
476+
These types are only available when using the Classic RESTEasy stack (quarkus-resteasy / quarkus-resteasy-jackson), which relies on the Servlet API provided by `quarkus-undertow` dependency.
477+
478+
To provide a Spring-friendly experience while staying reactive, Quarkus allows you to inject the following types into your `@ExceptionHandler` methods:
479+
480+
- io.vertx.core.http.HttpServerRequest
481+
482+
- io.vertx.core.http.HttpServerResponse
483+
484+
These types give you direct access to the underlying Vert.x HTTP layer.
485+
This allows you to manipulate the response (e.g. set headers, cookies, or status codes) or enrich the returned information using details from the request.
486+
487+
For example:
488+
489+
[source, java]
490+
----
491+
@ExceptionHandler(IllegalArgumentException.class)
492+
public ResponseEntity<Object> handleException(Exception ex,
493+
HttpServerRequest request,
494+
HttpServerResponse response) {
495+
// Add a custom header to the response
496+
response.putHeader("X-Error-Reason", "IllegalArgument");
497+
498+
// Build a response body enriched with request details
499+
String body = String.format("Request %s %s failed",
500+
request.method().name(),
501+
request.uri());
502+
503+
return new ResponseEntity<>(body, HttpStatus.BAD_REQUEST);
504+
}
505+
506+
----
507+
508+
**Warning:** This is potentially dangerous.
509+
Users should only do this if they understand the reactive model, and are aware that writing directly to the response can bypass normal handling of status codes, headers, and serialization.
510+
511+
472512
== Important Technical Note
473513

474514
Please note that the Spring support in Quarkus does not start a Spring Application Context nor are any Spring infrastructure classes run.

0 commit comments

Comments
 (0)