我正在将 AndroidAnnotations 与 Spring for Android 一起使用。由于某些原因,API 在每个请求中都需要一个特定的 QueryString-Parameter。所以我想通过拦截器添加它。
public class TestInterceptor implements ClientHttpRequestInterceptor {
@Override
public ClientHttpResponse intercept(HttpRequest httpRequest, byte[] bytes, ClientHttpRequestExecution clientHttpRequestExecution) throws IOException {
// how to safely add a constant querystring parameter to httpRequest here?
// e.g. http://myapi/test -> http://myapi/test?key=12345
// e.g. http://myapi/test?name=myname -> http://myapi/test?name=myname&key=12345
return clientHttpRequestExecution.execute(httpRequest, bytes);
}}