You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2017/10/31 10:24:36 UTC

[camel] branch camel-2.20.x updated (31db2d4 -> 8d092cc)

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a change to branch camel-2.20.x
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from 31db2d4  Regen
     new 5ad72ae  CAMEL-11951: Fixed rest-dsl uri matching when using matchOnUriPrefix to match more broadly should take in account http request method in use.
     new 8d092cc  Polished

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../common/HttpServletResolveConsumerStrategy.java | 23 ++++++++++++++++++++--
 .../jetty/rest/RestApiOverrideHostJettyTest.java   |  1 -
 2 files changed, 21 insertions(+), 3 deletions(-)

-- 
To stop receiving notification emails like this one, please contact
['"commits@camel.apache.org" <co...@camel.apache.org>'].

[camel] 01/02: CAMEL-11951: Fixed rest-dsl uri matching when using matchOnUriPrefix to match more broadly should take in account http request method in use.

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-2.20.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 5ad72ae41280611328aa127acb9213d26b0c7deb
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Oct 31 11:22:06 2017 +0100

    CAMEL-11951: Fixed rest-dsl uri matching when using matchOnUriPrefix to match more broadly should take in account http request method in use.
---
 .../common/HttpServletResolveConsumerStrategy.java | 23 ++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpServletResolveConsumerStrategy.java b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpServletResolveConsumerStrategy.java
index 027aca1..e55e650 100644
--- a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpServletResolveConsumerStrategy.java
+++ b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpServletResolveConsumerStrategy.java
@@ -16,7 +16,11 @@
  */
 package org.apache.camel.http.common;
 
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
 import java.util.Map;
+import java.util.stream.Collectors;
 import javax.servlet.http.HttpServletRequest;
 
 import org.apache.camel.support.RestConsumerContextPathMatcher;
@@ -35,6 +39,7 @@ public class HttpServletResolveConsumerStrategy implements ServletResolveConsume
         HttpConsumer answer = consumers.get(path);
 
         if (answer == null) {
+            List<HttpConsumer> candidates = new ArrayList<>();
             for (String key : consumers.keySet()) {
                 //We need to look up the consumer path here
                 String consumerPath = consumers.get(key).getPath();
@@ -42,8 +47,17 @@ public class HttpServletResolveConsumerStrategy implements ServletResolveConsume
                 boolean matchOnUriPrefix = consumer.getEndpoint().isMatchOnUriPrefix();
                 // Just make sure the we get the right consumer path first
                 if (RestConsumerContextPathMatcher.matchPath(path, consumerPath, matchOnUriPrefix)) {
-                    answer = consumers.get(key);
-                    break;
+                    candidates.add(consumer);
+                }
+            }
+
+            if (candidates.size() == 1) {
+                answer = candidates.get(0);
+            } else {
+                // extra filter by restrict
+                candidates = candidates.stream().filter(c -> matchRestMethod(request.getMethod(), c.getEndpoint().getHttpMethodRestrict())).collect(Collectors.toList());
+                if (candidates.size() == 1) {
+                    answer = candidates.get(0);
                 }
             }
         }
@@ -51,4 +65,9 @@ public class HttpServletResolveConsumerStrategy implements ServletResolveConsume
         return answer;
     }
 
+    private static boolean matchRestMethod(String method, String restrict) {
+        return restrict == null || restrict.toLowerCase(Locale.ENGLISH).contains(method.toLowerCase(Locale.ENGLISH));
+    }
+
+
 }

-- 
To stop receiving notification emails like this one, please contact
"commits@camel.apache.org" <co...@camel.apache.org>.

[camel] 02/02: Polished

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-2.20.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 8d092cce00cca368cdfc1f7a8a73df7447d7eced
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Oct 31 11:22:18 2017 +0100

    Polished
---
 .../apache/camel/component/jetty/rest/RestApiOverrideHostJettyTest.java  | 1 -
 1 file changed, 1 deletion(-)

diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/rest/RestApiOverrideHostJettyTest.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/rest/RestApiOverrideHostJettyTest.java
index 7fae3d0..9f07653 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/rest/RestApiOverrideHostJettyTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/rest/RestApiOverrideHostJettyTest.java
@@ -32,7 +32,6 @@ public class RestApiOverrideHostJettyTest extends BaseJettyTest {
     public void testApi() throws Exception {
         String out = template.requestBody("jetty:http://localhost:{{port}}/api-doc", null, String.class);
         assertNotNull(out);
-        System.out.println(out);
 
         assertTrue(out.contains("\"version\" : \"1.2.3\""));
         assertTrue(out.contains("\"title\" : \"The hello rest thing\""));

-- 
To stop receiving notification emails like this one, please contact
"commits@camel.apache.org" <co...@camel.apache.org>.