nacx requested changes on this pull request.
> +import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpRequestFilter;
+import org.jclouds.rest.annotations.ApiVersion;
+
+import com.google.common.net.HttpHeaders;
+
+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");
Remove the public modifier from the constructor and remove the null check.
> +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))
Do we want to override the Accept header, whatever it is? Or just append the
version if missing? Both approaches LGTM.
If we go for the former, then we could remove the `@Consumes` annotations from
the Api classes, since the header will be always put by this filter.
--
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#pullrequestreview-16328264