This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/master by this push:
new 4495866 Fix #184 Leverage platform http service
new ac84533 Merge pull request #201 from ppalaga/i184
4495866 is described below
commit 44958663793a7aee1fbc3616b59ffcd940c10230
Author: Peter Palaga <[email protected]>
AuthorDate: Thu Sep 26 12:10:27 2019 +0200
Fix #184 Leverage platform http service
---
.../ROOT/pages/_partials/component-extensions.adoc | 1 +
extensions/platform-http/component/pom.xml | 96 ++++++
.../platform/http/PlatformHttpComponent.java | 45 +++
.../platform/http/PlatformHttpConstants.java | 27 ++
.../platform/http/PlatformHttpEndpoint.java | 106 ++++++
.../http/PlatformHttpHeaderFilterStrategy.java | 54 +++
.../camel/component/platform/http/spi/Method.java | 74 ++++
.../platform/http/spi/PlatformHttpEngine.java | 37 ++
extensions/platform-http/deployment/pom.xml | 80 +++++
.../http/deployment/PlatformHttpProcessor.java | 43 +++
extensions/platform-http/pom.xml | 40 +++
extensions/platform-http/runtime/pom.xml | 84 +++++
.../http/runtime/PlatformHttpRecorder.java | 41 +++
.../http/runtime/QuarkusPlatformHttpConsumer.java | 380 +++++++++++++++++++++
.../http/runtime/QuarkusPlatformHttpEngine.java | 44 +++
extensions/pom.xml | 1 +
integration-tests/platform-http/pom.xml | 125 +++++++
.../platform/http/it/PlatformHttpRouteBuilder.java | 29 ++
.../src/main/resources/application.properties | 32 ++
.../component/http/server/it/PlatformHttpIT.java | 24 ++
.../component/http/server/it/PlatformHttpTest.java | 37 ++
integration-tests/pom.xml | 1 +
pom.xml | 1 +
poms/bom-deployment/pom.xml | 5 +
poms/bom/pom.xml | 25 ++
25 files changed, 1432 insertions(+)
diff --git a/docs/modules/ROOT/pages/_partials/component-extensions.adoc
b/docs/modules/ROOT/pages/_partials/component-extensions.adoc
index 30de83f..0481b4d 100644
--- a/docs/modules/ROOT/pages/_partials/component-extensions.adoc
+++ b/docs/modules/ROOT/pages/_partials/component-extensions.adoc
@@ -13,6 +13,7 @@
* `camel-quarkus-microprofile-metrics`
* `camel-quarkus-netty-http`
* `camel-quarkus-paho`
+* `camel-quarkus-platform-http`
* `camel-quarkus-rest`
* `camel-quarkus-salesforce`
* `camel-quarkus-servlet`
diff --git a/extensions/platform-http/component/pom.xml
b/extensions/platform-http/component/pom.xml
new file mode 100644
index 0000000..23428b9
--- /dev/null
+++ b/extensions/platform-http/component/pom.xml
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-platform-http-parent</artifactId>
+ <version>0.2.1-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-platform-http-component</artifactId>
+ <name>Camel Quarkus :: Platform HTTP :: Component</name>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-bom</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-support</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>spi-annotations</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>apt</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-package-maven-plugin</artifactId>
+ <version>${camel.version}</version>
+ <configuration>
+ <failFast>false</failFast>
+ </configuration>
+ <executions>
+ <execution>
+ <id>generate</id>
+ <goals>
+ <goal>prepare-components</goal>
+ </goals>
+ <phase>process-classes</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.jboss.jandex</groupId>
+ <artifactId>jandex-maven-plugin</artifactId>
+ <version>${jandex-maven-plugin.version}</version>
+ <executions>
+ <execution>
+ <id>make-index</id>
+ <goals>
+ <goal>jandex</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git
a/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/PlatformHttpComponent.java
b/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/PlatformHttpComponent.java
new file mode 100644
index 0000000..f2bec31
--- /dev/null
+++
b/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/PlatformHttpComponent.java
@@ -0,0 +1,45 @@
+/*
+ * 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.platform.http;
+
+import java.util.Map;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.spi.annotations.Component;
+import org.apache.camel.support.DefaultComponent;
+
+/**
+ * Exposes HTTP endpoints leveraging the given platform's (SpringBoot,
WildFly, Quarkus, ...) HTTP server.
+ */
+@Component("platform-http")
+public class PlatformHttpComponent extends DefaultComponent {
+
+ public PlatformHttpComponent() {
+ super();
+ }
+
+ public PlatformHttpComponent(CamelContext context) {
+ super(context);
+ }
+
+ @Override
+ protected Endpoint createEndpoint(String uri, String remaining,
Map<String, Object> parameters) throws Exception {
+ return new PlatformHttpEndpoint(uri, remaining, this);
+ }
+
+}
diff --git
a/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/PlatformHttpConstants.java
b/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/PlatformHttpConstants.java
new file mode 100644
index 0000000..3fba42b
--- /dev/null
+++
b/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/PlatformHttpConstants.java
@@ -0,0 +1,27 @@
+/*
+ * 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.platform.http;
+
+public final class PlatformHttpConstants {
+
+ public static final String PLATFORM_HTTP_COMPONENT_NAME = "platform-http";
+ public static final String PLATFORM_HTTP_ENGINE_NAME =
"platformHttpEngine";
+
+ private PlatformHttpConstants() {
+ }
+
+}
diff --git
a/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/PlatformHttpEndpoint.java
b/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/PlatformHttpEndpoint.java
new file mode 100644
index 0000000..b394b18
--- /dev/null
+++
b/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/PlatformHttpEndpoint.java
@@ -0,0 +1,106 @@
+/*
+ * 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.platform.http;
+
+import org.apache.camel.AsyncEndpoint;
+import org.apache.camel.Component;
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.component.platform.http.spi.PlatformHttpEngine;
+import org.apache.camel.spi.HeaderFilterStrategy;
+import org.apache.camel.spi.HeaderFilterStrategyAware;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.support.DefaultEndpoint;
+
+@UriEndpoint(/* firstVersion = "3.?.0", */ scheme = "platform-http", title =
"Platform HTTP", syntax = "platform-http:[methods:]path", label = "http")
+public class PlatformHttpEndpoint extends DefaultEndpoint implements
AsyncEndpoint, HeaderFilterStrategyAware {
+
+ private final String path;
+
+ @UriParam(label = "consumer", description = "A comma separated list of
HTTP methods to serve, e.g. GET,POST ."
+ + " If no methods are specified, all methods will be served.")
+ private String httpMethodRestrict;
+
+ @UriParam(label = "advanced")
+ private PlatformHttpEngine platformHttpEngine;
+
+ @UriParam(label = "advanced")
+ private HeaderFilterStrategy headerFilterStrategy = new
PlatformHttpHeaderFilterStrategy();
+
+ public PlatformHttpEndpoint(String uri, String remaining, Component
component) {
+ super(uri, component);
+ path = remaining;
+ }
+
+ @Override
+ public Producer createProducer() throws Exception {
+ throw new UnsupportedOperationException("Producer is not supported");
+ }
+
+ @Override
+ public Consumer createConsumer(Processor processor) throws Exception {
+ return platformHttpEngine.createConsumer(this, processor);
+ }
+
+ @Override
+ public HeaderFilterStrategy getHeaderFilterStrategy() {
+ return headerFilterStrategy;
+ }
+
+ @Override
+ public void setHeaderFilterStrategy(HeaderFilterStrategy
headerFilterStrategy) {
+ this.headerFilterStrategy = headerFilterStrategy;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public PlatformHttpEngine getPlatformHttpEngine() {
+ return platformHttpEngine;
+ }
+
+ public void setPlatformHttpEngine(PlatformHttpEngine platformHttpEngine) {
+ this.platformHttpEngine = platformHttpEngine;
+ }
+
+ public String getHttpMethodRestrict() {
+ return httpMethodRestrict;
+ }
+
+ public void setHttpMethodRestrict(String httpMethodRestrict) {
+ this.httpMethodRestrict = httpMethodRestrict;
+ }
+
+ @Override
+ protected void doStart() throws Exception {
+ super.doStart();
+ if (platformHttpEngine == null) {
+ platformHttpEngine = getCamelContext().getRegistry()
+
.lookupByNameAndType(PlatformHttpConstants.PLATFORM_HTTP_ENGINE_NAME,
PlatformHttpEngine.class);
+ if (platformHttpEngine == null) {
+ throw new
IllegalStateException(PlatformHttpEngine.class.getSimpleName() + " neither set
on this "
+ + PlatformHttpEndpoint.class.getSimpleName() + "
neither found in Camel Registry.");
+ }
+ }
+ }
+
+
+
+}
diff --git
a/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/PlatformHttpHeaderFilterStrategy.java
b/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/PlatformHttpHeaderFilterStrategy.java
new file mode 100644
index 0000000..49253ec
--- /dev/null
+++
b/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/PlatformHttpHeaderFilterStrategy.java
@@ -0,0 +1,54 @@
+/*
+ * 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.platform.http;
+
+import org.apache.camel.support.DefaultHeaderFilterStrategy;
+
+/**
+ * A copy of {@code org.apache.camel.http.common.HttpHeaderFilterStrategy}.
Keep in sync or refactor
+ * {@code camel-http-common} not to depend on {@code javax.servlet-api} and
then use the {@code HttpHeaderFilterStrategy}
+ * from there.
+ */
+public class PlatformHttpHeaderFilterStrategy extends
DefaultHeaderFilterStrategy {
+
+ public PlatformHttpHeaderFilterStrategy() {
+ initialize();
+ }
+
+ protected void initialize() {
+ getOutFilter().add("content-length");
+ getOutFilter().add("content-type");
+ getOutFilter().add("host");
+ // Add the filter for the Generic Message header
+ // http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.5
+ getOutFilter().add("cache-control");
+ getOutFilter().add("connection");
+ getOutFilter().add("date");
+ getOutFilter().add("pragma");
+ getOutFilter().add("trailer");
+ getOutFilter().add("transfer-encoding");
+ getOutFilter().add("upgrade");
+ getOutFilter().add("via");
+ getOutFilter().add("warning");
+
+ setLowerCase(true);
+
+ // filter headers begin with "Camel" or "org.apache.camel"
+ // must ignore case for Http based transports
+
setOutFilterPattern("(?i)(Camel|org\\.apache\\.camel)[\\.|a-z|A-z|0-9]*");
+ }
+}
diff --git
a/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/spi/Method.java
b/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/spi/Method.java
new file mode 100644
index 0000000..2d628cf
--- /dev/null
+++
b/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/spi/Method.java
@@ -0,0 +1,74 @@
+/*
+ * 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.platform.http.spi;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Locale;
+import java.util.Set;
+import java.util.TreeSet;
+
+/**
+ * An HTTP method.
+ */
+public enum Method {
+ GET(false), HEAD(false), POST(true), PUT(true), DELETE(false),
TRACE(false), OPTIONS(false), CONNECT(false), PATCH(
+ true);
+ private static final Set<Method> ALL = Collections.unmodifiableSet(new
TreeSet<>(Arrays.asList(values())));
+ private final boolean canHaveBody;
+
+ private Method(boolean canHaveBody) {
+ this.canHaveBody = canHaveBody;
+ }
+
+ public static Set<Method> getAll() {
+ return ALL;
+ }
+
+ /**
+ * @return {@code true} if HTTP requests with this {@link Method} can have
a body; {@code false} otherwise
+ */
+ public boolean canHaveBody() {
+ return canHaveBody;
+ }
+
+ /**
+ * Parse the given comma separated {@code methodList} to a {@link Set} of
{@link Method}s. If {@code methodList} is
+ * empty or {@code null} returns {@link #ALL}.
+ *
+ * @param methodList a comma separated list of HTTP method names.
+ * @return a {@link Set} of {@link Method}s
+ */
+ public static Set<Method> parseList(String methodList) {
+ if (methodList == null) {
+ return ALL;
+ }
+ methodList = methodList.toUpperCase(Locale.ROOT);
+ String[] methods = methodList.split(",");
+ if (methods.length == 0) {
+ return ALL;
+ } else if (methods.length == 1) {
+ return Collections.singleton(Method.valueOf(methods[0]));
+ } else {
+ Set<Method> result = new TreeSet<>();
+ for (String method : methods) {
+ result.add(Method.valueOf(method.trim()));
+ }
+ return ALL.equals(result) ? ALL :
Collections.unmodifiableSet(result);
+ }
+ }
+}
\ No newline at end of file
diff --git
a/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/spi/PlatformHttpEngine.java
b/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/spi/PlatformHttpEngine.java
new file mode 100644
index 0000000..c78d993
--- /dev/null
+++
b/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/spi/PlatformHttpEngine.java
@@ -0,0 +1,37 @@
+/*
+ * 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.platform.http.spi;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.component.platform.http.PlatformHttpEndpoint;
+
+/**
+ * An abstraction of an HTTP Server engine on which HTTP endpoints can be
deployed.
+ */
+public interface PlatformHttpEngine {
+
+ /**
+ * Creates a new {@link Consumer} for the given {@link
PlatformHttpEndpoint}.
+ *
+ * @param platformHttpEndpoint the {@link PlatformHttpEndpoint} to creat a
consumer for
+ * @param processor the Processor to pass to
+ * @return a new {@link Consumer}
+ */
+ Consumer createConsumer(PlatformHttpEndpoint platformHttpEndpoint,
Processor processor);
+
+}
diff --git a/extensions/platform-http/deployment/pom.xml
b/extensions/platform-http/deployment/pom.xml
new file mode 100644
index 0000000..3e17778
--- /dev/null
+++ b/extensions/platform-http/deployment/pom.xml
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-platform-http-parent</artifactId>
+ <version>0.2.1-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-platform-http-deployment</artifactId>
+ <name>Camel Quarkus :: Platform HTTP :: Deployment</name>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-bom-deployment</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-core-deployment</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-platform-http</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-vertx-web-deployment</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <annotationProcessorPaths>
+ <path>
+ <groupId>io.quarkus</groupId>
+
<artifactId>quarkus-extension-processor</artifactId>
+ <version>${quarkus.version}</version>
+ </path>
+ </annotationProcessorPaths>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git
a/extensions/platform-http/deployment/src/main/java/org/apache/camel/quarkus/component/platform/http/deployment/PlatformHttpProcessor.java
b/extensions/platform-http/deployment/src/main/java/org/apache/camel/quarkus/component/platform/http/deployment/PlatformHttpProcessor.java
new file mode 100644
index 0000000..4b61333
--- /dev/null
+++
b/extensions/platform-http/deployment/src/main/java/org/apache/camel/quarkus/component/platform/http/deployment/PlatformHttpProcessor.java
@@ -0,0 +1,43 @@
+/*
+ * 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.quarkus.component.platform.http.deployment;
+
+import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.annotations.ExecutionTime;
+import io.quarkus.deployment.annotations.Record;
+import io.quarkus.deployment.builditem.FeatureBuildItem;
+import io.quarkus.vertx.http.deployment.VertxWebRouterBuildItem;
+
+import
org.apache.camel.quarkus.component.platform.http.runtime.PlatformHttpRecorder;
+import org.apache.camel.quarkus.core.deployment.CamelRuntimeBuildItem;
+
+class PlatformHttpProcessor {
+
+ private static final String FEATURE = "camel-platform-http";
+
+ @BuildStep
+ FeatureBuildItem feature() {
+ return new FeatureBuildItem(FEATURE);
+ }
+
+ @Record(ExecutionTime.RUNTIME_INIT)
+ @BuildStep
+ void platformHttpComponent(PlatformHttpRecorder recorder,
CamelRuntimeBuildItem runtime, VertxWebRouterBuildItem router) {
+ recorder.registerPlatformHttpComponent(runtime.getRuntime(),
router.getRouter());
+ }
+
+}
diff --git a/extensions/platform-http/pom.xml b/extensions/platform-http/pom.xml
new file mode 100644
index 0000000..ec00876
--- /dev/null
+++ b/extensions/platform-http/pom.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-build-parent</artifactId>
+ <version>0.2.1-SNAPSHOT</version>
+ <relativePath>../../poms/build-parent/pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-platform-http-parent</artifactId>
+ <name>Camel Quarkus :: Platform HTTP</name>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>component</module>
+ <module>deployment</module>
+ <module>runtime</module>
+ </modules>
+</project>
diff --git a/extensions/platform-http/runtime/pom.xml
b/extensions/platform-http/runtime/pom.xml
new file mode 100644
index 0000000..73427a6
--- /dev/null
+++ b/extensions/platform-http/runtime/pom.xml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-platform-http-parent</artifactId>
+ <version>0.2.1-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-platform-http</artifactId>
+ <name>Camel Quarkus :: Platform HTTP :: Runtime</name>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-bom</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-platform-http-component</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-vertx-web</artifactId>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-bootstrap-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <annotationProcessorPaths>
+ <path>
+ <groupId>io.quarkus</groupId>
+
<artifactId>quarkus-extension-processor</artifactId>
+ <version>${quarkus.version}</version>
+ </path>
+ </annotationProcessorPaths>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git
a/extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/PlatformHttpRecorder.java
b/extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/PlatformHttpRecorder.java
new file mode 100644
index 0000000..36ac31a
--- /dev/null
+++
b/extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/PlatformHttpRecorder.java
@@ -0,0 +1,41 @@
+/*
+ * 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.quarkus.component.platform.http.runtime;
+
+import io.quarkus.runtime.RuntimeValue;
+import io.quarkus.runtime.annotations.Recorder;
+import io.vertx.ext.web.Router;
+
+import org.apache.camel.component.platform.http.PlatformHttpComponent;
+import org.apache.camel.component.platform.http.PlatformHttpConstants;
+import org.apache.camel.component.platform.http.spi.PlatformHttpEngine;
+import org.apache.camel.quarkus.core.runtime.CamelRuntime;
+import org.apache.camel.spi.Registry;
+
+@Recorder
+public class PlatformHttpRecorder {
+
+ public void registerPlatformHttpComponent(RuntimeValue<CamelRuntime>
runtime, RuntimeValue<Router> router) {
+ final Registry registry = runtime.getValue().getRegistry();
+ final PlatformHttpEngine engine = new
QuarkusPlatformHttpEngine(router.getValue());
+ registry.bind(PlatformHttpConstants.PLATFORM_HTTP_ENGINE_NAME,
PlatformHttpEngine.class, engine);
+
+ final PlatformHttpComponent component = new
PlatformHttpComponent(runtime.getValue().getContext());
+ registry.bind(PlatformHttpConstants.PLATFORM_HTTP_COMPONENT_NAME,
PlatformHttpComponent.class, component);
+ }
+
+}
diff --git
a/extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/QuarkusPlatformHttpConsumer.java
b/extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/QuarkusPlatformHttpConsumer.java
new file mode 100644
index 0000000..f1e53d6
--- /dev/null
+++
b/extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/QuarkusPlatformHttpConsumer.java
@@ -0,0 +1,380 @@
+/*
+ * 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.quarkus.component.platform.http.runtime;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import io.vertx.core.MultiMap;
+import io.vertx.core.buffer.Buffer;
+import io.vertx.core.http.HttpMethod;
+import io.vertx.core.http.HttpServerRequest;
+import io.vertx.core.http.HttpServerResponse;
+import io.vertx.ext.web.Route;
+import io.vertx.ext.web.Router;
+import io.vertx.ext.web.RoutingContext;
+import io.vertx.ext.web.handler.BodyHandler;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.NoTypeConversionAvailableException;
+import org.apache.camel.Processor;
+import org.apache.camel.TypeConversionException;
+import org.apache.camel.TypeConverter;
+import org.apache.camel.component.platform.http.PlatformHttpComponent;
+import org.apache.camel.component.platform.http.PlatformHttpEndpoint;
+import org.apache.camel.component.platform.http.spi.Method;
+import org.apache.camel.spi.HeaderFilterStrategy;
+import org.apache.camel.support.DefaultConsumer;
+import org.apache.camel.support.DefaultMessage;
+import org.apache.camel.support.ExchangeHelper;
+import org.apache.camel.support.MessageHelper;
+import org.apache.camel.support.ObjectHelper;
+import org.eclipse.microprofile.config.Config;
+import org.eclipse.microprofile.config.ConfigProvider;
+import org.jboss.logging.Logger;
+
+/**
+ * A Quarkus specific {@link Consumer} for the {@link PlatformHttpComponent}.
+ */
+public class QuarkusPlatformHttpConsumer extends DefaultConsumer {
+ private static final Logger LOG =
Logger.getLogger(QuarkusPlatformHttpConsumer.class);
+
+ private final Router router;
+ private Route route;
+
+ public QuarkusPlatformHttpConsumer(Endpoint endpoint, Processor processor,
Router router) {
+ super(endpoint, processor);
+ this.router = router;
+ }
+
+ @Override
+ public PlatformHttpEndpoint getEndpoint() {
+ return (PlatformHttpEndpoint) super.getEndpoint();
+ }
+
+ @Override
+ protected void doStart() throws Exception {
+ super.doStart();
+
+ final String path = getEndpoint().getPath();
+ final Route newRoute = router.route(path);
+
+ final Set<Method> methods =
Method.parseList(getEndpoint().getHttpMethodRestrict());
+ if (!methods.equals(Method.getAll())) {
+ methods.stream().forEach(m ->
newRoute.method(HttpMethod.valueOf(m.name())));
+ }
+
+ Config cfg = ConfigProvider.getConfig();
+ final BodyHandler bodyHandler = BodyHandler.create();
+ /* Keep in sync with how the BodyHandler is configured in
io.quarkus.vertx.web.runtime.VertxWebRecorder
+ * Eventually, VertxWebRecorder should have a method to do this for
us. */
+ cfg.getOptionalValue("quarkus.http.body.handle-file-uploads",
boolean.class).ifPresent(bodyHandler::setHandleFileUploads);
+ cfg.getOptionalValue("quarkus.http.body.uploads-directory",
String.class).ifPresent(bodyHandler::setUploadsDirectory);
+ cfg.getOptionalValue("quarkus.http.body.delete-uploaded-files-on-end",
boolean.class).ifPresent(bodyHandler::setDeleteUploadedFilesOnEnd);
+ cfg.getOptionalValue("quarkus.http.body.merge-form-attributes",
boolean.class).ifPresent(bodyHandler::setMergeFormAttributes);
+ cfg.getOptionalValue("quarkus.http.body.preallocate-body-buffer",
boolean.class).ifPresent(bodyHandler::setPreallocateBodyBuffer);
+
+ newRoute
+ .handler(bodyHandler)
+ .handler(ctx -> {
+ try {
+ final PlatformHttpEndpoint endpoint = getEndpoint();
+ final HeaderFilterStrategy headerFilterStrategy =
endpoint.getHeaderFilterStrategy();
+ final Exchange e = toExchange(ctx,
endpoint.createExchange(), headerFilterStrategy);
+ getProcessor().process(e);
+ writeResponse(ctx, e, headerFilterStrategy);
+ } catch (Exception e1) {
+ LOG.debugf(e1, "Could not handle '%s'", path);
+ ctx.fail(e1);
+ }
+ });
+
+ this.route = newRoute;
+ }
+
+ @Override
+ protected void doStop() throws Exception {
+ if (route != null) {
+ route.remove();
+ route = null;
+ }
+ super.doStop();
+ }
+
+ @Override
+ protected void doSuspend() throws Exception {
+ if (route != null) {
+ route.disable();
+ }
+ super.doSuspend();
+ }
+
+ @Override
+ protected void doResume() throws Exception {
+ if (route != null) {
+ route.enable();
+ }
+ super.doResume();
+ }
+
+ Object toHttpResponse(HttpServerResponse response, Message message,
HeaderFilterStrategy headerFilterStrategy) {
+ final Exchange exchange = message.getExchange();
+ final boolean failed = exchange.isFailed();
+ final int defaultCode = failed ? 500 : 200;
+
+ final int code = message.getHeader(Exchange.HTTP_RESPONSE_CODE,
defaultCode, int.class);
+
+ response.setStatusCode(code);
+
+ final TypeConverter tc = exchange.getContext().getTypeConverter();
+
+ //copy headers from Message to Response
+ if (headerFilterStrategy != null) {
+ for (Map.Entry<String, Object> entry :
message.getHeaders().entrySet()) {
+ final String key = entry.getKey();
+ final Object value = entry.getValue();
+ // use an iterator as there can be multiple values. (must not
use a delimiter)
+ final Iterator<?> it = ObjectHelper.createIterator(value,
null);
+ String firstValue = null;
+ List<String> values = null;
+ while (it.hasNext()) {
+ final String headerValue = tc.convertTo(String.class,
it.next());
+ if (headerValue != null
+ &&
!headerFilterStrategy.applyFilterToCamelHeaders(key, headerValue, exchange)) {
+ if (firstValue == null) {
+ firstValue = headerValue;
+ } else {
+ if (values == null) {
+ values = new ArrayList<String>();
+ values.add(firstValue);
+ }
+ values.add(headerValue);
+ }
+ }
+ }
+ if (values != null) {
+ response.putHeader(key, values);
+ } else if (firstValue != null) {
+ response.putHeader(key, firstValue);
+ }
+ }
+ }
+
+ Object body = message.getBody();
+ final Exception exception = exchange.getException();
+
+ if (exception != null) {
+ // we failed due an exception so print it as plain text
+ final StringWriter sw = new StringWriter();
+ final PrintWriter pw = new PrintWriter(sw);
+ exception.printStackTrace(pw);
+
+ // the body should then be the stacktrace
+ body =
ByteBuffer.wrap(sw.toString().getBytes(StandardCharsets.UTF_8));
+ // force content type to be text/plain as that is what the
stacktrace is
+ message.setHeader(Exchange.CONTENT_TYPE, "text/plain;
charset=utf-8");
+
+ // and mark the exception as failure handled, as we handled it by
returning it as the response
+ ExchangeHelper.setFailureHandled(exchange);
+ }
+
+ // set the content type in the response.
+ final String contentType = MessageHelper.getContentType(message);
+ if (contentType != null) {
+ // set content-type
+ response.putHeader("Content-Type", contentType);
+ }
+ return body;
+ }
+
+ void writeResponse(RoutingContext ctx, Exchange camelExchange,
HeaderFilterStrategy headerFilterStrategy) {
+ final Object body = toHttpResponse(ctx.response(),
camelExchange.getMessage(), headerFilterStrategy);
+
+ final HttpServerResponse response = ctx.response();
+ if (body == null) {
+ LOG.tracef("No payload to send as reply for exchange: %s",
camelExchange);
+ response.putHeader("Content-Type", "text/plain; charset=utf-8");
+ response.end("No response available");
+ return;
+ }
+
+ if (body instanceof String) {
+ response.end((String) body);
+ } else if (body instanceof InputStream) {
+ final byte[] bytes = new byte[4096];
+ try (InputStream in = (InputStream) body) {
+ int len;
+ while ((len = in.read(bytes)) >= 0) {
+ final Buffer b = Buffer.buffer(len);
+ b.appendBytes(bytes, 0, len);
+ response.write(b);
+ }
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ response.end();
+ } else {
+ final TypeConverter tc =
camelExchange.getContext().getTypeConverter();
+ try {
+ final ByteBuffer bb = tc.mandatoryConvertTo(ByteBuffer.class,
body);
+ final Buffer b = Buffer.buffer(bb.capacity());
+ b.setBytes(0, bb);
+ response.end(b);
+ } catch (TypeConversionException |
NoTypeConversionAvailableException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ }
+
+ Exchange toExchange(RoutingContext ctx, Exchange exchange,
HeaderFilterStrategy headerFilterStrategy) {
+ Message in = toCamelMessage(ctx, exchange, headerFilterStrategy);
+
+ final String charset =
ctx.parsedHeaders().contentType().parameter("charset");
+ if (charset != null) {
+ exchange.setProperty(Exchange.CHARSET_NAME, charset);
+ in.setHeader(Exchange.HTTP_CHARACTER_ENCODING, charset);
+ }
+
+ exchange.setIn(in);
+ return exchange;
+ }
+
+ void populateCamelHeaders(RoutingContext ctx, Map<String, Object>
headersMap, Exchange exchange,
+ HeaderFilterStrategy headerFilterStrategy) {
+
+ final HttpServerRequest request = ctx.request();
+ headersMap.put(Exchange.HTTP_PATH, request.path());
+
+ if (headerFilterStrategy != null) {
+ final MultiMap requestHeaders = request.headers();
+ final String authz = requestHeaders.get("authorization");
+ // store a special header that this request was authenticated
using HTTP Basic
+ if (authz != null && authz.trim().startsWith("Basic")) {
+ if
(!headerFilterStrategy.applyFilterToExternalHeaders(Exchange.AUTHENTICATION,
"Basic", exchange)) {
+ appendHeader(headersMap, Exchange.AUTHENTICATION, "Basic");
+ }
+ }
+ for (String name : requestHeaders.names()) {
+ // add the headers one by one, and use the header filter
strategy
+ for (String value : requestHeaders.getAll(name)) {
+ if
(!headerFilterStrategy.applyFilterToExternalHeaders(name.toString(), value,
exchange)) {
+ appendHeader(headersMap, name.toString(), value);
+ }
+ }
+ }
+
+ // process uri parameters as headers
+ final MultiMap pathParameters = ctx.queryParams();
+ // continue if the map is not empty, otherwise there are no params
+ if (!pathParameters.isEmpty()) {
+ for (String name : pathParameters.names()) {
+ for (String value : pathParameters.getAll(name)) {
+ if
(!headerFilterStrategy.applyFilterToExternalHeaders(name, value, exchange)) {
+ appendHeader(headersMap, name, value);
+ }
+ }
+ }
+ }
+ }
+
+ // TODO: figure out whether we need this or remove
+ // // Create headers for REST path placeholder variables
+ // Map<String, Object> predicateContextParams =
httpExchange.getAttachment(Predicate.PREDICATE_CONTEXT);
+ // if (predicateContextParams != null) {
+ // // Remove this as it's an unwanted artifact of our
Undertow predicate chain
+ // predicateContextParams.remove("remaining");
+ //
+ // for (String paramName : predicateContextParams.keySet())
{
+ // headersMap.put(paramName,
predicateContextParams.get(paramName));
+ // }
+ // }
+
+ // NOTE: these headers is applied using the same logic as
camel-http/camel-jetty to be consistent
+ headersMap.put(Exchange.HTTP_METHOD, request.method().toString());
+ // strip query parameters from the uri
+ headersMap.put(Exchange.HTTP_URL, request.absoluteURI());
+ // uri is without the host and port
+ headersMap.put(Exchange.HTTP_URI, request.uri());
+ headersMap.put(Exchange.HTTP_QUERY, request.query());
+ headersMap.put(Exchange.HTTP_RAW_QUERY, request.query());
+ }
+
+ Message toCamelMessage(RoutingContext ctx, Exchange exchange,
HeaderFilterStrategy headerFilterStrategy) {
+ Message result = new DefaultMessage(exchange);
+
+ populateCamelHeaders(ctx, result.getHeaders(), exchange,
headerFilterStrategy);
+ final String mimeType = ctx.parsedHeaders().contentType().value();
+ if ("application/x-www-form-urlencoded".equals(mimeType) ||
"multipart/form-data".equals(mimeType)) {
+ final MultiMap formData = ctx.request().formAttributes();
+ final Map<String, Object> body = new HashMap<>();
+ for (String key : formData.names()) {
+ for (String value : formData.getAll(key)) {
+ if (headerFilterStrategy != null
+ &&
!headerFilterStrategy.applyFilterToExternalHeaders(key, value, exchange)) {
+ appendHeader(result.getHeaders(), key, value);
+ appendHeader(body, key, value);
+ }
+ }
+ }
+ result.setBody(body);
+ } else {
+ //extract body by myself if undertow parser didn't handle and the
method is allowed to have one
+ //body is extracted as byte[] then auto TypeConverter kicks in
+ Method m = Method.valueOf(ctx.request().method().name());
+ if (m.canHaveBody()) {
+ final Buffer body = ctx.getBody();
+ result.setBody(body.getBytes());
+ } else {
+ result.setBody(null);
+ }
+ }
+ return result;
+ }
+
+ @SuppressWarnings("unchecked")
+ static void appendHeader(Map<String, Object> headers, String key, Object
value) {
+ if (headers.containsKey(key)) {
+ Object existing = headers.get(key);
+ List<Object> list;
+ if (existing instanceof List) {
+ list = (List<Object>) existing;
+ } else {
+ list = new ArrayList<>();
+ list.add(existing);
+ }
+ list.add(value);
+ value = list;
+ }
+
+ headers.put(key, value);
+ }
+
+}
\ No newline at end of file
diff --git
a/extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/QuarkusPlatformHttpEngine.java
b/extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/QuarkusPlatformHttpEngine.java
new file mode 100644
index 0000000..244f766
--- /dev/null
+++
b/extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/QuarkusPlatformHttpEngine.java
@@ -0,0 +1,44 @@
+/*
+ * 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.quarkus.component.platform.http.runtime;
+
+import io.vertx.ext.web.Router;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.component.platform.http.PlatformHttpEndpoint;
+import org.apache.camel.component.platform.http.spi.PlatformHttpEngine;
+import org.jboss.logging.Logger;
+
+
+public class QuarkusPlatformHttpEngine implements PlatformHttpEngine {
+
+ static final Logger LOG =
Logger.getLogger(QuarkusPlatformHttpEngine.class);
+
+ private final Router router;
+
+ public QuarkusPlatformHttpEngine(Router router) {
+ super();
+ this.router = router;
+ }
+
+ @Override
+ public Consumer createConsumer(PlatformHttpEndpoint endpoint, Processor
processor) {
+ return new QuarkusPlatformHttpConsumer(endpoint, processor, router);
+ }
+
+}
diff --git a/extensions/pom.xml b/extensions/pom.xml
index 43cfda2..1096421 100644
--- a/extensions/pom.xml
+++ b/extensions/pom.xml
@@ -62,6 +62,7 @@
<module>csv</module>
<module>microprofile-metrics</module>
<module>paho</module>
+ <module>platform-http</module>
</modules>
<build>
diff --git a/integration-tests/platform-http/pom.xml
b/integration-tests/platform-http/pom.xml
new file mode 100644
index 0000000..fb9e5ee
--- /dev/null
+++ b/integration-tests/platform-http/pom.xml
@@ -0,0 +1,125 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-integration-tests</artifactId>
+ <version>0.2.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-quarkus-integration-test-platform-http</artifactId>
+ <name>Camel Quarkus :: Integration Tests :: platform-http</name>
+ <description>Integration tests for Camel Quarkus platform-http
extension</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-platform-http</artifactId>
+ </dependency>
+
+ <!-- test dependencies -->
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-junit5</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.rest-assured</groupId>
+ <artifactId>rest-assured</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>build</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>native-image</id>
+ <activation>
+ <property>
+ <name>native</name>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ <configuration>
+ <systemProperties>
+
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
+ </systemProperties>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>native-image</id>
+ <goals>
+ <goal>native-image</goal>
+ </goals>
+ <configuration>
+
<reportErrorsAtRuntime>false</reportErrorsAtRuntime>
+ <cleanupServer>true</cleanupServer>
+
<enableHttpsUrlHandler>true</enableHttpsUrlHandler>
+
<enableHttpUrlHandler>true</enableHttpUrlHandler>
+ <enableServer>false</enableServer>
+ <dumpProxies>false</dumpProxies>
+ <graalvmHome>${graalvmHome}</graalvmHome>
+ <enableJni>true</enableJni>
+
<enableAllSecurityServices>true</enableAllSecurityServices>
+ <disableReports>true</disableReports>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+</project>
diff --git
a/integration-tests/platform-http/src/main/java/org/apache/camel/quarkus/component/platform/http/it/PlatformHttpRouteBuilder.java
b/integration-tests/platform-http/src/main/java/org/apache/camel/quarkus/component/platform/http/it/PlatformHttpRouteBuilder.java
new file mode 100644
index 0000000..26147af
--- /dev/null
+++
b/integration-tests/platform-http/src/main/java/org/apache/camel/quarkus/component/platform/http/it/PlatformHttpRouteBuilder.java
@@ -0,0 +1,29 @@
+/*
+ * 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.quarkus.component.platform.http.it;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class PlatformHttpRouteBuilder extends RouteBuilder {
+
+ @Override
+ public void configure() {
+
from("platform-http:/platform-http/hello?httpMethodRestrict=GET").setBody(simple("Hello
${header.name}"));
+
from("platform-http:/platform-http/get-post?httpMethodRestrict=GET,POST").setBody(simple("Hello
${body}"));
+
from("platform-http:/platform-http/multipart?httpMethodRestrict=POST").setBody(simple("Hello
${body}"));
+ }
+}
diff --git
a/integration-tests/platform-http/src/main/resources/application.properties
b/integration-tests/platform-http/src/main/resources/application.properties
new file mode 100644
index 0000000..460b930
--- /dev/null
+++ b/integration-tests/platform-http/src/main/resources/application.properties
@@ -0,0 +1,32 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+#
+# Quarkus
+#
+quarkus.ssl.native=true
+quarkus.log.file.enable = false
+quarkus.log.category."org.apache.camel.quarkus.component.platform.http".level
= DEBUG
+
+#
+# Quarkus :: Camel
+#
+quarkus.camel.disable-xml=true
+quarkus.camel.disable-jaxb=true
+
+# A workaround for https://github.com/quarkusio/quarkus/issues/4047
+# can be removed after an upgrade to Quarkus 0.23.0
+quarkus.vertx-http.port = 8081
diff --git
a/integration-tests/platform-http/src/test/java/org/apache/camel/quarkus/component/http/server/it/PlatformHttpIT.java
b/integration-tests/platform-http/src/test/java/org/apache/camel/quarkus/component/http/server/it/PlatformHttpIT.java
new file mode 100644
index 0000000..8a5fa8c
--- /dev/null
+++
b/integration-tests/platform-http/src/test/java/org/apache/camel/quarkus/component/http/server/it/PlatformHttpIT.java
@@ -0,0 +1,24 @@
+/*
+ * 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.quarkus.component.http.server.it;
+
+import io.quarkus.test.junit.SubstrateTest;
+
+@SubstrateTest
+class PlatformHttpIT extends PlatformHttpTest {
+
+}
diff --git
a/integration-tests/platform-http/src/test/java/org/apache/camel/quarkus/component/http/server/it/PlatformHttpTest.java
b/integration-tests/platform-http/src/test/java/org/apache/camel/quarkus/component/http/server/it/PlatformHttpTest.java
new file mode 100644
index 0000000..b12bf7e
--- /dev/null
+++
b/integration-tests/platform-http/src/test/java/org/apache/camel/quarkus/component/http/server/it/PlatformHttpTest.java
@@ -0,0 +1,37 @@
+/*
+ * 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.quarkus.component.http.server.it;
+
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+
+import org.junit.jupiter.api.Test;
+import static org.hamcrest.core.IsEqual.equalTo;
+
+
+@QuarkusTest
+class PlatformHttpTest {
+
+ @Test
+ public void basic() {
+ RestAssured.given().param("name",
"Kermit").get("/platform-http/hello").then().statusCode(200).body(equalTo("Hello
Kermit"));
+ RestAssured.post("/platform-http/hello").then().statusCode(405);
+
RestAssured.given().body("Camel").post("/platform-http/get-post").then().statusCode(200).body(equalTo("Hello
Camel"));
+
RestAssured.given().get("/platform-http/get-post").then().statusCode(200).body(equalTo("Hello
")); // there is no body for get
+ }
+
+}
diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml
index 6037bdf..6a2e76c 100644
--- a/integration-tests/pom.xml
+++ b/integration-tests/pom.xml
@@ -95,6 +95,7 @@
<module>zipfile</module>
<module>microprofile-metrics</module>
<module>paho</module>
+ <module>platform-http</module>
</modules>
<build>
diff --git a/pom.xml b/pom.xml
index 4108dcb..74f0a30 100644
--- a/pom.xml
+++ b/pom.xml
@@ -57,6 +57,7 @@
<exec-maven-plugin.version>1.6.0</exec-maven-plugin.version>
<groovy-maven-plugin.version>2.1.1</groovy-maven-plugin.version>
<groovy.version>2.5.8</groovy.version>
+ <jandex-maven-plugin.version>1.0.6</jandex-maven-plugin.version>
<mycila-license.version>3.0</mycila-license.version>
<maven-gpg-plugin.version>1.6</maven-gpg-plugin.version>
<maven-deploy-plugin.version>3.0.0-M1</maven-deploy-plugin.version>
diff --git a/poms/bom-deployment/pom.xml b/poms/bom-deployment/pom.xml
index 0f3553e..1d512a2 100644
--- a/poms/bom-deployment/pom.xml
+++ b/poms/bom-deployment/pom.xml
@@ -200,6 +200,11 @@
<artifactId>camel-quarkus-paho-deployment</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-platform-http-deployment</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
</dependencyManagement>
diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml
index 55eb9c9..6a503c0 100644
--- a/poms/bom/pom.xml
+++ b/poms/bom/pom.xml
@@ -51,6 +51,11 @@
<!-- Camel (in alphabetical order) -->
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>apt</artifactId>
+ <version>${camel.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-aws-eks</artifactId>
<version>${camel.version}</version>
</dependency>
@@ -198,6 +203,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>camel-support</artifactId>
+ <version>${camel.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-timer</artifactId>
<version>${camel.version}</version>
</dependency>
@@ -211,6 +221,11 @@
<artifactId>camel-zipfile</artifactId>
<version>${camel.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>spi-annotations</artifactId>
+ <version>${camel.version}</version>
+ </dependency>
<!-- Camel Quarkus Support (in alphabetical order) -->
<dependency>
@@ -359,6 +374,16 @@
<artifactId>camel-quarkus-paho</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-platform-http</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-platform-http-component</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
</dependencyManagement>