PreProcessInterceptor更改QueryParam的值

时间:2018-12-04 17:40:20

标签: java interceptor grpc-java

我需要为我们的许多其余端点动态更改特定的查询参数。我正在尝试使用PreProcessInterceptor实现此目的。

@Provider
@ServerInterceptor
public class SwapCarName implements PreProcessInterceptor {


    @Override
    public ServerResponse preProcess(HttpRequest request, ResourceMethod method) throws Failure, WebApplicationException {
       UriBuilder builder = request.getUri().getRequestUriBuilder();

        builder.replaceQueryParam( "carName",”blah”).build();

        // Prints the old value
        LOGGER.debug("After=" + request.getUri().getQueryParameters().getFirst("carName"));

        return null;
    }
}

上面的代码不会更改查询参数carName的值。我在拦截器方面没有太多经验。你能帮忙吗?谢谢

0 个答案:

没有答案