You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2019/10/24 15:13:49 UTC

[camel-quarkus] 02/04: Fix #324 Document the platform-http extension

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

lburgazzoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git

commit 228bec793ad5faa4294210a4a5ccac56eb52b0e9
Author: Peter Palaga <pp...@redhat.com>
AuthorDate: Wed Oct 23 11:45:46 2019 +0200

    Fix #324 Document the platform-http extension
---
 .../ROOT/pages/extensions/platform-http.adoc       | 99 ++++++++++++++++++++++
 .../pages/list-of-camel-quarkus-extensions.adoc    |  2 +-
 extensions/readme.adoc                             |  2 +-
 3 files changed, 101 insertions(+), 2 deletions(-)

diff --git a/docs/modules/ROOT/pages/extensions/platform-http.adoc b/docs/modules/ROOT/pages/extensions/platform-http.adoc
new file mode 100644
index 0000000..658e17f
--- /dev/null
+++ b/docs/modules/ROOT/pages/extensions/platform-http.adoc
@@ -0,0 +1,99 @@
+[[platform-http]]
+= Platform HTTP Extension
+
+*Since Camel Quarkus 0.3.0*
+
+This extension allows for creating HTTP endpoints for consuming HTTP requests.
+
+It is built on top of Eclipse Wert.x Web service provided by the `quarkus-vertx-web` extension.
+
+To use this extension add the following dependency to your `pom.xml`:
+
+[source,xml]
+----
+<dependency>
+    <groupId>org.apache.camel.quarkus</groupId>
+    <artifactId>camel-quarkus-platform-http</artifactId>
+</dependency>
+----
+
+
+== Basic Usage
+
+Serve all HTTP methods on the `/hello` endpoint:
+
+[source,java]
+----
+from("platform-http:/hello").setBody(simple("Hello ${header.name}"));
+----
+
+Serve only GET requests on the `/hello` endpoint:
+
+[source,java]
+----
+from("platform-http:/hello?httpMethodRestrict=GET").setBody(simple("Hello ${header.name}"));
+----
+
+== Using `platform-http` via Camel REST DSL
+
+To be able to use Camel REST DSL with the `platform-http` component, add `camel-quarkus-rest` in addition to `camel-quarkus-platform-http` to your `pom.xml`:
+
+[source,xml]
+----
+<dependency>
+    <groupId>org.apache.camel.quarkus</groupId>
+    <artifactId>camel-quarkus-rest</artifactId>
+</dependency>
+----
+
+Then you can use the Camel REST DSL:
+
+[source,java]
+----
+rest()
+    .get("/my-get-endpoint")
+        .route()
+        .setBody(constant("Hello from /my-get-endpoint"))
+        .endRest()
+    .post("/my-post-endpoint")
+        .route()
+        .setBody(constant("Hello from /my-post-endpoint"))
+        .endRest();
+----
+
+
+== Handling `multipart/form-data` file uploads
+
+If you want Camel Quarkus to attach uploaded files to Camel messages for you, you need to add the following optional
+dependency to your `pom.xml`:
+
+[source,xml]
+----
+<dependency>
+    <groupId>org.apache.camel.quarkus</groupId>
+    <artifactId>camel-quarkus-attachments</artifactId>
+</dependency>
+----
+
+You can restrict the uploads to certain file extensions by white listing them:
+
+[source,java]
+----
+from("platform-http:/upload/multipart?fileNameExtWhitelist=adoc,txt&httpMethodRestrict=POST")
+    .to("log:multipart")
+    .process(e -> {
+        final AttachmentMessage am = e.getMessage(AttachmentMessage.class);
+        if (am.hasAttachments()) {
+            am.getAttachments().forEach((fileName, dataHandler) -> {
+                try (InputStream in = dataHandler.getInputStream()) {
+                    // do something with the input stream
+                } catch (IOException ioe) {
+                    throw new RuntimeException(ioe);
+                }
+            });
+        }
+    });
+----
+
+Also check the `quarkus.http.body.*` configuration options in
+https://quarkus.io/guides/all-config[Quarkus documentation], esp. `quarkus.http.body.handle-file-uploads`, `quarkus.http.body.uploads-directory` and `quarkus.http.body.delete-uploaded-files-on-end`.
diff --git a/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc b/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc
index d1d9923..3f247bf 100644
--- a/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc
+++ b/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc
@@ -140,7 +140,7 @@ Number of miscellaneous extensions: 7 in 7 JAR artifacts (0 deprecated)
 
 | (camel-quarkus-core-cloud) | 0.2 | The Camel Quarkus core cloud module
 
-| (camel-quarkus-platform-http) | 0.2.1 | HTTP platform component is used for integrating Camel HTTP with Quarkus HTTP layer
+| xref:extensions/platform-http.adoc[camel-quarkus-platform-http]  | 0.2.1 | HTTP platform component is used for integrating Camel HTTP with Quarkus HTTP layer
 
 | (camel-quarkus-reactive-executor) | 0.2.1 | To use Quarkus reactive executor with Camel
 
diff --git a/extensions/readme.adoc b/extensions/readme.adoc
index 49929c2..27c3d2d 100644
--- a/extensions/readme.adoc
+++ b/extensions/readme.adoc
@@ -142,7 +142,7 @@ Number of miscellaneous extensions: 7 in 7 JAR artifacts (0 deprecated)
 
 | (camel-quarkus-core-cloud) | 0.2 | The Camel Quarkus core cloud module
 
-| (camel-quarkus-platform-http) | 0.2.1 | HTTP platform component is used for integrating Camel HTTP with Quarkus HTTP layer
+| xref:extensions/platform-http.adoc[camel-quarkus-platform-http]  | 0.2.1 | HTTP platform component is used for integrating Camel HTTP with Quarkus HTTP layer
 
 | (camel-quarkus-reactive-executor) | 0.2.1 | To use Quarkus reactive executor with Camel