File tree 1 file changed +11
-2
lines changed
docs/modules/ROOT/pages/spring-cloud-gateway-server-mvc/filters
1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -5,20 +5,29 @@ You can use the `ModifyResponseBody` filter to modify the response body before i
5
5
6
6
NOTE: This filter can be configured only by using the Java DSL.
7
7
8
- The following listing shows how to modify a response body filter:
8
+ The following listing shows how to modify a response body filter:
9
9
10
+ .GatewaySampleApplication.java
10
11
[source,java]
11
12
----
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
+
12
18
@Bean
13
19
public RouterFunction<ServerResponse> gatewayRouterFunctionsModifyResponseBodySimple() {
14
20
return route("modify_response_body")
15
21
.GET("/anything/modifyresponsebody", http())
16
- .before(new HttpbinUriResolver( ))
22
+ .before(uri("https://example.org" ))
17
23
.after(modifyResponseBody(String.class, String.class, null,
18
24
(request, response, s) -> s.replace("fooval", "FOOVAL")))
19
25
.build();
20
26
}
21
27
----
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
+
22
31
.GatewaySampleApplication.java
23
32
[source,java]
24
33
----
You can’t perform that action at this time.
0 commit comments