Skip to content

Commit 8f534eb

Browse files
committed
polishing modifyresponsebody.adoc
1 parent afd4e0a commit 8f534eb

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

docs/modules/ROOT/pages/spring-cloud-gateway-server-mvc/filters/modifyresponsebody.adoc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,29 @@ You can use the `ModifyResponseBody` filter to modify the response body before i
55

66
NOTE: This filter can be configured only by using the Java DSL.
77

8-
The following listing shows how to modify a response body filter:
8+
The following listing shows how to modify a response body filter:
99

10+
.GatewaySampleApplication.java
1011
[source,java]
1112
----
13+
import static org.springframework.cloud.gateway.server.mvc.filter.AfterFilterFunctions.modifyResponseBody;
14+
import static org.springframework.cloud.gateway.server.mvc.filter.BeforeFilterFunctions.uri;
15+
import static org.springframework.cloud.gateway.server.mvc.handler.GatewayRouterFunctions.route;
16+
import static org.springframework.cloud.gateway.server.mvc.handler.HandlerFunctions.http;
17+
1218
@Bean
1319
public RouterFunction<ServerResponse> gatewayRouterFunctionsModifyResponseBodySimple() {
1420
return route("modify_response_body")
1521
.GET("/anything/modifyresponsebody", http())
16-
.before(new HttpbinUriResolver())
22+
.before(uri("https://example.org"))
1723
.after(modifyResponseBody(String.class, String.class, null,
1824
(request, response, s) -> s.replace("fooval", "FOOVAL")))
1925
.build();
2026
}
2127
----
28+
29+
The sample above does not change the content type or do anything dynamic. Below, the sample changes the content type and dynamically modifies the content.
30+
2231
.GatewaySampleApplication.java
2332
[source,java]
2433
----

0 commit comments

Comments
 (0)