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/01/17 13:28:12 UTC
[3/3] camel git commit: CAMEL-10691:
HttpRestServletResolveConsumerStrategy should pick the path with longest
prefix match
CAMEL-10691: HttpRestServletResolveConsumerStrategy should pick the path with longest prefix match
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/555627d4
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/555627d4
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/555627d4
Branch: refs/heads/master
Commit: 555627d49e48df00f325ec05f382b79415cadffc
Parents: 91ccd59
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Jan 17 14:03:10 2017 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Jan 17 14:03:10 2017 +0100
----------------------------------------------------------------------
.../http/handlers/HttpRestConsumerPath.java | 53 ++++++++++++++++++++
.../HttpServerMultiplexChannelHandler.java | 17 +------
2 files changed, 54 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/555627d4/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/handlers/HttpRestConsumerPath.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/handlers/HttpRestConsumerPath.java b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/handlers/HttpRestConsumerPath.java
new file mode 100644
index 0000000..184032b
--- /dev/null
+++ b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/handlers/HttpRestConsumerPath.java
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF 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 org.apache.camel.component.netty4.http.handlers;
+
+import org.apache.camel.support.RestConsumerContextPathMatcher;
+
+public class HttpRestConsumerPath implements RestConsumerContextPathMatcher.ConsumerPath<HttpServerChannelHandler> {
+
+ private final HttpServerChannelHandler handler;
+
+ public HttpRestConsumerPath(HttpServerChannelHandler handler) {
+ this.handler = handler;
+ }
+
+ @Override
+ public String getRestrictMethod() {
+ return handler.getConsumer().getEndpoint().getHttpMethodRestrict();
+ }
+
+ @Override
+ public String getConsumerPath() {
+ return handler.getConsumer().getConfiguration().getPath();
+ }
+
+ @Override
+ public HttpServerChannelHandler getConsumer() {
+ return handler;
+ }
+
+ @Override
+ public boolean isMatchOnUriPrefix() {
+ return handler.getConsumer().getEndpoint().getConfiguration().isMatchOnUriPrefix();
+ }
+
+ @Override
+ public String toString() {
+ return getConsumerPath();
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/555627d4/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/handlers/HttpServerMultiplexChannelHandler.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/handlers/HttpServerMultiplexChannelHandler.java b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/handlers/HttpServerMultiplexChannelHandler.java
index fd8cb04..fdf16fb 100644
--- a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/handlers/HttpServerMultiplexChannelHandler.java
+++ b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/handlers/HttpServerMultiplexChannelHandler.java
@@ -165,22 +165,7 @@ public class HttpServerMultiplexChannelHandler extends SimpleChannelInboundHandl
List<RestConsumerContextPathMatcher.ConsumerPath> paths = new ArrayList<RestConsumerContextPathMatcher.ConsumerPath>();
for (final HttpServerChannelHandler handler : consumers) {
- paths.add(new RestConsumerContextPathMatcher.ConsumerPath<HttpServerChannelHandler>() {
- @Override
- public String getRestrictMethod() {
- return handler.getConsumer().getEndpoint().getHttpMethodRestrict();
- }
-
- @Override
- public String getConsumerPath() {
- return handler.getConsumer().getConfiguration().getPath();
- }
-
- @Override
- public HttpServerChannelHandler getConsumer() {
- return handler;
- }
- });
+ paths.add(new HttpRestConsumerPath(handler));
}
RestConsumerContextPathMatcher.ConsumerPath<HttpServerChannelHandler> best = RestConsumerContextPathMatcher.matchBestPath(method, path, paths);