You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2019/12/20 09:01:33 UTC
[camel] 04/06: CAMEL-14303: Add platform-http match on uri prefix
fix.
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit c73c556e3bbbd6c5a006645710416f1f12a14426
Author: Bob Paulin <bo...@bobpaulin.com>
AuthorDate: Thu Dec 19 21:23:22 2019 -0600
CAMEL-14303: Add platform-http match on uri prefix fix.
---
.../platform/http/PlatformHttpComponent.java | 35 +++++-----------------
1 file changed, 8 insertions(+), 27 deletions(-)
diff --git a/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/PlatformHttpComponent.java b/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/PlatformHttpComponent.java
index 86afc1f..92a2fa6 100644
--- a/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/PlatformHttpComponent.java
+++ b/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/PlatformHttpComponent.java
@@ -31,6 +31,7 @@ import org.apache.camel.spi.RestConfiguration;
import org.apache.camel.spi.RestConsumerFactory;
import org.apache.camel.spi.annotations.Component;
import org.apache.camel.support.DefaultComponent;
+import org.apache.camel.support.RestComponentHelper;
import org.apache.camel.util.FileUtil;
import org.apache.camel.util.URISupport;
@@ -108,43 +109,23 @@ public class PlatformHttpComponent extends DefaultComponent implements RestConsu
config = camelContext.getRestConfiguration(PlatformHttpConstants.PLATFORM_HTTP_COMPONENT_NAME, true);
}
- Map<String, Object> map = new HashMap<>();
- // build query string, and append any endpoint configuration properties
- if (config.getComponent() == null || config.getComponent().equals(PlatformHttpConstants.PLATFORM_HTTP_COMPONENT_NAME)) {
- // setup endpoint options
- if (config.getEndpointProperties() != null && !config.getEndpointProperties().isEmpty()) {
- map.putAll(config.getEndpointProperties());
- }
- }
+ Map<String, Object> map = RestComponentHelper.initRestEndpointProperties(PlatformHttpConstants.PLATFORM_HTTP_COMPONENT_NAME, config);
boolean cors = config.isEnableCORS();
if (cors) {
// allow HTTP Options as we want to handle CORS in rest-dsl
map.put("optionsEnabled", "true");
}
-
- // do not append with context-path as the servlet path should be without context-path
-
- String query = URISupport.createQueryString(map);
-
- String url;
+
if (api) {
- url = "platform-http:/%s?matchOnUriPrefix=true&httpMethodRestrict=%s";
- } else {
- url = "platform-http:/%s?httpMethodRestrict=%s";
+ map.put("matchOnUriPrefix", "true");
}
+
+ RestComponentHelper.addHttpRestrictParam(map, verb, cors);
- // must use upper case for restrict
- String restrict = verb.toUpperCase(Locale.US);
- if (cors) {
- restrict += ",OPTIONS";
- }
- // get the endpoint
- url = String.format(url, path, restrict);
+ // do not append with context-path as the servlet path should be without context-path
- if (!query.isEmpty()) {
- url = url + "&" + query;
- }
+ String url = RestComponentHelper.createRestConsumerUrl("platform-http", path, map);
PlatformHttpEndpoint endpoint = camelContext.getEndpoint(url, PlatformHttpEndpoint.class);
setProperties(camelContext, endpoint, parameters);