-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1550 from michalszynkiewicz/incoming-headers
RestClient - passing incoming JAX-RS headers, fixes #1017
- Loading branch information
Showing
10 changed files
with
132 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...runtime/src/main/java/io/quarkus/smallrye/restclient/runtime/IncomingHeadersProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright (c) 2019 Red Hat, Inc. | ||
* | ||
* Red Hat licenses this file to you under the Apache License, version | ||
* 2.0 (the "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
* implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
package io.quarkus.smallrye.restclient.runtime; | ||
|
||
import javax.ws.rs.core.MultivaluedHashMap; | ||
import javax.ws.rs.core.MultivaluedMap; | ||
|
||
import org.jboss.resteasy.specimpl.UnmodifiableMultivaluedMap; | ||
import org.jboss.resteasy.spi.HttpRequest; | ||
import org.jboss.resteasy.spi.ResteasyProviderFactory; | ||
|
||
/** | ||
* @author Michal Szynkiewicz, michal.l.szynkiewicz@gmail.com | ||
* <br> | ||
* Date: 2/28/19 | ||
*/ | ||
public class IncomingHeadersProvider implements io.smallrye.restclient.header.IncomingHeadersProvider { | ||
public static final UnmodifiableMultivaluedMap<String, String> EMPTY_MAP = new UnmodifiableMultivaluedMap<>( | ||
new MultivaluedHashMap<>()); | ||
|
||
/** | ||
* @return headers incoming in the JAX-RS request, if any | ||
*/ | ||
@Override | ||
public MultivaluedMap<String, String> getIncomingHeaders() { | ||
MultivaluedMap<String, String> result = null; | ||
|
||
ResteasyProviderFactory providerFactory = ResteasyProviderFactory.peekInstance(); | ||
if (providerFactory != null) { | ||
HttpRequest request = (HttpRequest) providerFactory.getContextData(HttpRequest.class); | ||
if (request != null) { | ||
result = request.getHttpHeaders().getRequestHeaders(); | ||
} | ||
} | ||
return result == null | ||
? EMPTY_MAP | ||
: result; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...rc/main/resources/META-INF/services/io.smallrye.restclient.header.IncomingHeadersProvider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
io.quarkus.smallrye.restclient.runtime.IncomingHeadersProvider |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
integration-tests/main/src/main/resources/META-INF/microprofile-config.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.eclipse.microprofile.rest.client.propagateHeaders=header-name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters