jclouds-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrea Turli <notificati...@github.com>
Subject Re: [jclouds/jclouds-labs] add AddApiVersionToRequest filter (#343)
Date Sat, 14 Jan 2017 10:40:17 GMT
andreaturli commented on this pull request.



> +import static com.google.common.base.Preconditions.checkNotNull;
+
+@Singleton
+public class AddApiVersionToRequest implements HttpRequestFilter {
+
+    private final String apiVersion;
+
+    @Inject
+    public AddApiVersionToRequest(@ApiVersion String apiVersion) {
+        this.apiVersion = checkNotNull(apiVersion, "apiVersion");
+    }
+
+    @Override
+    public HttpRequest filter(final HttpRequest request) throws HttpException {
+        return request.toBuilder()
+                .replaceHeader(HttpHeaders.ACCEPT, String.format("application/json; version=%s",
apiVersion))

I've slightly modified the logic, it now gets the previous `accept` header, which must be
there because of @Consume, and append the `version=<value>` to it

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/343
Mime
View raw message