commercetools / commercetools-sdk-java-v2

The e-commerce SDK from commercetools for Java.
https://commercetools.github.io/commercetools-sdk-java-v2/javadoc/index.html
Apache License 2.0
35 stars 16 forks source link

Is it possible to enhance headers for example `User-Agent` header ? #99

Closed ahmetoz closed 3 years ago

ahmetoz commented 3 years ago

I want to add a header as below for the User-Agent and an existing header might stay: custom-client , commercetools-java-sdks/1.6.0 Java/13.0.2+8 (Mac OS X; x86_64)

But I could not change the user-agent client, by default middleware overrides it. I think currently the only way is creating all middleware from scratch, or I am missing something?

https://github.com/commercetools/commercetools-sdk-java-v2/blob/910581c3ae361c83135585969a0fbc75f4ab32cd/rmf/rmf-java-base/src/main/java/io/vrap/rmf/base/client/MiddlewareFactory.java#L23-L26


apiClient = ApiFactory.defaultClient(
            ClientCredentials.of().withClientId(clientId)
                             .withClientSecret(clientSecret)
                             .build(),
            ServiceRegion.GCP_EUROPE_WEST1.getOAuthTokenUrl(),
            ServiceRegion.GCP_EUROPE_WEST1.getApiUrl(),
            Collections.singletonList(
                (request, next) -> next.apply(request.withHeader(ApiHttpHeaders.USER_AGENT, "custom-client"))
            )
        );
jenschude commented 3 years ago

Will come in the next release. See 5efb81b

ahmetoz commented 3 years ago

Thanks for addressing it, I will check when it's released 👍🏽