0

I have some gateway filters written

@Bean
public RouteLocator routes(
  RouteLocatorBuilder builder,
  LoggingGatewayFilterFactory loggingFactory) {
    return builder.routes()
      .route("service_route_java_config", r -> r.path("/service/**")
        .filters(f -> 
            f.rewritePath("/service(?<segment>/?.*)", "$\\{segment}")
            .uri("http://localhost:8081"))
      .build();
}

I need to replace some string in a response body, I got this reference link but am not sure where to add the TestFilter2 kind of AbstractGatewayFilterFactory in the above routing filter.

Also I tried this logic but getting null pointer if the response body is null

     route("routing, r -> r .path("/settings/system/**") 
    .filters(f -> f.rewritepath("/settings/system", "/system") 
    .modifyresponsebody(string.class, string.class, (exchange, s) -> mono.just(s).flatmap(value -> { 
    if(value != null) return mono.just(value.replace("system","settings/system"));
    else return mono.just(s); }))
    .uri(https://myip:443)

How to handle Mano if the response is null?

scoder
  • 2,451
  • 4
  • 30
  • 70

0 Answers0