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

nfilotto pushed a commit to branch CAMEL-17792/doc-message-headers
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 77b228fbcf3279bcd0861f0cbbf36fcabb749eee
Author: Nicolas Filotto <[email protected]>
AuthorDate: Wed Apr 6 12:04:23 2022 +0200

    CAMEL-17792: Add doc about the message headers of camel-vertx-http
---
 .../camel/component/vertx/http/vertx-http.json     | 10 +++++++
 .../src/main/docs/vertx-http-component.adoc        | 31 ++-------------------
 .../vertx/http/DefaultVertxHttpBinding.java        | 12 ++++----
 .../component/vertx/http/VertxHttpConstants.java   | 32 ++++++++++++++++++++++
 .../component/vertx/http/VertxHttpEndpoint.java    |  3 +-
 .../component/vertx/http/VertxHttpHelper.java      | 10 +++----
 6 files changed, 58 insertions(+), 40 deletions(-)

diff --git 
a/components/camel-vertx/camel-vertx-http/src/generated/resources/org/apache/camel/component/vertx/http/vertx-http.json
 
b/components/camel-vertx/camel-vertx-http/src/generated/resources/org/apache/camel/component/vertx/http/vertx-http.json
index 166bf34ff93..3d5fed86a6b 100644
--- 
a/components/camel-vertx/camel-vertx-http/src/generated/resources/org/apache/camel/component/vertx/http/vertx-http.json
+++ 
b/components/camel-vertx/camel-vertx-http/src/generated/resources/org/apache/camel/component/vertx/http/vertx-http.json
@@ -41,6 +41,16 @@
     "sslContextParameters": { "kind": "property", "displayName": "Ssl Context 
Parameters", "group": "security", "label": "security", "required": false, 
"type": "object", "javaType": 
"org.apache.camel.support.jsse.SSLContextParameters", "deprecated": false, 
"autowired": false, "secret": false, "description": "To configure security 
using SSLContextParameters" },
     "useGlobalSslContextParameters": { "kind": "property", "displayName": "Use 
Global Ssl Context Parameters", "group": "security", "label": "security", 
"required": false, "type": "boolean", "javaType": "boolean", "deprecated": 
false, "autowired": false, "secret": false, "defaultValue": false, 
"description": "Enable usage of global SSL context parameters" }
   },
+  "headers": {
+    "CamelHttpMethod": { "kind": "header", "displayName": "", "group": 
"producer", "label": "", "required": false, "javaType": 
"io.vertx.core.http.HttpMethod", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "The http method" },
+    "CamelHttpResponseCode": { "kind": "header", "displayName": "", "group": 
"producer", "label": "", "required": false, "javaType": "Integer", 
"deprecated": false, "deprecationNote": "", "autowired": false, "secret": 
false, "description": "The HTTP response code from the external server." },
+    "CamelHttpResponseText": { "kind": "header", "displayName": "", "group": 
"producer", "label": "", "required": false, "javaType": "String", "deprecated": 
false, "deprecationNote": "", "autowired": false, "secret": false, 
"description": "The HTTP response text from the external server." },
+    "Content-Type": { "kind": "header", "displayName": "", "group": 
"producer", "label": "", "required": false, "javaType": "String", "deprecated": 
false, "deprecationNote": "", "autowired": false, "secret": false, 
"description": "The HTTP content type. Is set on both the IN and OUT message to 
provide a content type, such as text\/html." },
+    "CamelHttpQuery": { "kind": "header", "displayName": "", "group": 
"producer", "label": "", "required": false, "javaType": "String", "deprecated": 
false, "deprecationNote": "", "autowired": false, "secret": false, 
"description": "URI parameters. Will override existing URI parameters set 
directly on the endpoint." },
+    "CamelHttpUri": { "kind": "header", "displayName": "", "group": 
"producer", "label": "", "required": false, "javaType": "String", "deprecated": 
false, "deprecationNote": "", "autowired": false, "secret": false, 
"description": "URI to call. Will override the existing URI set directly on the 
endpoint. This URI is the URI of the http server to call. Its not the same as 
the Camel endpoint URI, where you can configure endpoint options such as 
security etc. This header does not support tha [...]
+    "CamelHttpPath": { "kind": "header", "displayName": "", "group": 
"producer", "label": "", "required": false, "javaType": "String", "deprecated": 
false, "deprecationNote": "", "autowired": false, "secret": false, 
"description": "Request URI's path, the header will be used to build the 
request URI with the HTTP_URI." },
+    "Content-Encoding": { "kind": "header", "displayName": "", "group": 
"producer", "label": "", "required": false, "javaType": "String", "deprecated": 
false, "deprecationNote": "", "autowired": false, "secret": false, 
"description": "The HTTP content encoding. Is set to provide a content 
encoding, such as gzip." }
+  },
   "properties": {
     "httpUri": { "kind": "path", "displayName": "Http Uri", "group": 
"producer", "label": "", "required": true, "type": "string", "javaType": 
"java.net.URI", "deprecated": false, "deprecationNote": "", "autowired": false, 
"secret": false, "configurationClass": 
"org.apache.camel.component.vertx.http.VertxHttpConfiguration", 
"configurationField": "configuration", "description": "The HTTP URI to connect 
to" },
     "connectTimeout": { "kind": "parameter", "displayName": "Connect Timeout", 
"group": "producer", "label": "producer", "required": false, "type": "integer", 
"javaType": "int", "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": 60000, "configurationClass": 
"org.apache.camel.component.vertx.http.VertxHttpConfiguration", 
"configurationField": "configuration", "description": "The amount of time in 
milliseconds until a connection is established. A timeout value of zer [...]
diff --git 
a/components/camel-vertx/camel-vertx-http/src/main/docs/vertx-http-component.adoc
 
b/components/camel-vertx/camel-vertx-http/src/main/docs/vertx-http-component.adoc
index 24ff70a1e00..5a9ba99ea9a 100644
--- 
a/components/camel-vertx/camel-vertx-http/src/main/docs/vertx-http-component.adoc
+++ 
b/components/camel-vertx/camel-vertx-http/src/main/docs/vertx-http-component.adoc
@@ -49,34 +49,9 @@ include::partial$component-endpoint-options.adoc[]
 
 // endpoint options: END
 
-
-== Message Headers
-
-[width="100%",cols="10%,20%,70%",options="header",]
-|=======================================================================
-|Name |Type |Description
-
-|`Exchange.HTTP_URI` |`String` |URI to call. Will override the existing URI 
set directly on the endpoint.
-This URI is the URI of the http server to call. Its not the same as the
-Camel endpoint URI, where you can configure endpoint options such as
-security etc. This header does not support that, its only the URI of the
-http server.
-
-|`Exchange.HTTP_PATH` |`String` |Request URI's path, the header will be used 
to build the request URI
-with the HTTP_URI.
-
-|`Exchange.HTTP_QUERY` |`String` |URI parameters. Will override existing URI 
parameters set directly on
-the endpoint.
-
-|`Exchange.HTTP_RESPONSE_CODE` |`int` |The HTTP response code from the 
external server.
-
-|`Exchange.HTTP_RESPONSE_TEXT` | `String` |The HTTP response text from the 
external server.
-
-|`Exchange.CONTENT_TYPE` |`String` |The HTTP content type. Is set on both the 
IN and OUT message to provide
-a content type, such as `text/html`.
-
-|`Exchange.CONTENT_ENCODING` |`String` |The HTTP content encoding. Is set to 
provide a content encoding, such as `gzip`.
-|=======================================================================
+// component headers: START
+include::partial$component-endpoint-headers.adoc[]
+// component headers: END
 
 == Usage
 The following example shows how to send a request to an HTTP endpoint.
diff --git 
a/components/camel-vertx/camel-vertx-http/src/main/java/org/apache/camel/component/vertx/http/DefaultVertxHttpBinding.java
 
b/components/camel-vertx/camel-vertx-http/src/main/java/org/apache/camel/component/vertx/http/DefaultVertxHttpBinding.java
index 1f5660fa6d4..54490a9f810 100644
--- 
a/components/camel-vertx/camel-vertx-http/src/main/java/org/apache/camel/component/vertx/http/DefaultVertxHttpBinding.java
+++ 
b/components/camel-vertx/camel-vertx-http/src/main/java/org/apache/camel/component/vertx/http/DefaultVertxHttpBinding.java
@@ -66,7 +66,7 @@ public class DefaultVertxHttpBinding implements 
VertxHttpBinding {
         }
 
         // Determine the HTTP method to use if not specified in the 
HTTP_METHOD header
-        HttpMethod method = message.getHeader(Exchange.HTTP_METHOD, 
configuration.getHttpMethod(), HttpMethod.class);
+        HttpMethod method = message.getHeader(VertxHttpConstants.HTTP_METHOD, 
configuration.getHttpMethod(), HttpMethod.class);
         if (method == null) {
             if (ObjectHelper.isNotEmpty(queryString)) {
                 method = HttpMethod.GET;
@@ -126,7 +126,7 @@ public class DefaultVertxHttpBinding implements 
VertxHttpBinding {
         // Ensure the Content-Type header is always added if the corresponding 
exchange header is present
         String contentType = ExchangeHelper.getContentType(exchange);
         if (ObjectHelper.isNotEmpty(contentType)) {
-            headers.add(Exchange.CONTENT_TYPE, contentType);
+            headers.add(VertxHttpConstants.CONTENT_TYPE, contentType);
         }
 
         // Transfer exchange headers to the HTTP request while applying the 
filter strategy
@@ -165,8 +165,8 @@ public class DefaultVertxHttpBinding implements 
VertxHttpBinding {
     @Override
     public void populateResponseHeaders(Exchange exchange, 
HttpResponse<Buffer> response, HeaderFilterStrategy strategy) {
         Message message = exchange.getMessage();
-        message.setHeader(Exchange.HTTP_RESPONSE_CODE, response.statusCode());
-        message.setHeader(Exchange.HTTP_RESPONSE_TEXT, 
response.statusMessage());
+        message.setHeader(VertxHttpConstants.HTTP_RESPONSE_CODE, 
response.statusCode());
+        message.setHeader(VertxHttpConstants.HTTP_RESPONSE_TEXT, 
response.statusMessage());
 
         MultiMap headers = response.headers();
         headers.forEach(new Consumer<Map.Entry<String, String>>() {
@@ -178,7 +178,7 @@ public class DefaultVertxHttpBinding implements 
VertxHttpBinding {
                 String value = entry.getValue();
                 if (!found && name.equalsIgnoreCase("content-type")) {
                     found = true;
-                    name = Exchange.CONTENT_TYPE;
+                    name = VertxHttpConstants.CONTENT_TYPE;
                     exchange.setProperty(ExchangePropertyKey.CHARSET_NAME, 
IOHelper.getCharsetNameFromContentType(value));
                 }
                 Object extracted = HttpHelper.extractHttpParameterValue(value);
@@ -195,7 +195,7 @@ public class DefaultVertxHttpBinding implements 
VertxHttpBinding {
             throws Exception {
         Buffer responseBody = result.body();
         if (responseBody != null) {
-            String contentType = result.getHeader(Exchange.CONTENT_TYPE);
+            String contentType = 
result.getHeader(VertxHttpConstants.CONTENT_TYPE);
             if (CONTENT_TYPE_JAVA_SERIALIZED_OBJECT.equals(contentType)) {
                 boolean transferException = 
endpoint.getConfiguration().isTransferException();
                 boolean allowJavaSerializedObject = 
endpoint.getComponent().isAllowJavaSerializedObject();
diff --git 
a/components/camel-vertx/camel-vertx-http/src/main/java/org/apache/camel/component/vertx/http/VertxHttpConstants.java
 
b/components/camel-vertx/camel-vertx-http/src/main/java/org/apache/camel/component/vertx/http/VertxHttpConstants.java
index e451a485139..d6421bb0291 100644
--- 
a/components/camel-vertx/camel-vertx-http/src/main/java/org/apache/camel/component/vertx/http/VertxHttpConstants.java
+++ 
b/components/camel-vertx/camel-vertx-http/src/main/java/org/apache/camel/component/vertx/http/VertxHttpConstants.java
@@ -16,11 +16,43 @@
  */
 package org.apache.camel.component.vertx.http;
 
+import org.apache.camel.Exchange;
+import org.apache.camel.spi.Metadata;
+
 public final class VertxHttpConstants {
 
     public static final String CONTENT_TYPE_JAVA_SERIALIZED_OBJECT = 
"application/x-java-serialized-object";
     public static final String CONTENT_TYPE_FORM_URLENCODED = 
"application/x-www-form-urlencoded";
 
+    @Metadata(description = "The http method", javaType = 
"io.vertx.core.http.HttpMethod")
+    public static final String HTTP_METHOD = Exchange.HTTP_METHOD;
+    @Metadata(description = "The HTTP response code from the external 
server.", javaType = "Integer")
+    public static final String HTTP_RESPONSE_CODE = 
Exchange.HTTP_RESPONSE_CODE;
+    @Metadata(description = "The HTTP response text from the external 
server.", javaType = "String")
+    public static final String HTTP_RESPONSE_TEXT = 
Exchange.HTTP_RESPONSE_TEXT;
+    @Metadata(description = "The HTTP content type. Is set on both the IN and 
OUT message to provide\n" +
+                            "a content type, such as `text/html`.",
+              javaType = "String")
+    public static final String CONTENT_TYPE = Exchange.CONTENT_TYPE;
+    @Metadata(description = "URI parameters. Will override existing URI 
parameters set directly on\n" +
+                            "the endpoint.",
+              javaType = "String")
+    public static final String HTTP_QUERY = Exchange.HTTP_QUERY;
+    @Metadata(description = "URI to call. Will override the existing URI set 
directly on the endpoint.\n" +
+                            "This URI is the URI of the http server to call. 
Its not the same as the\n" +
+                            "Camel endpoint URI, where you can configure 
endpoint options such as\n" +
+                            "security etc. This header does not support that, 
its only the URI of the\n" +
+                            "http server.",
+              javaType = "String")
+    public static final String HTTP_URI = Exchange.HTTP_URI;
+    @Metadata(description = "Request URI's path, the header will be used to 
build the request URI\n" +
+                            "with the HTTP_URI.",
+              javaType = "String")
+    public static final String HTTP_PATH = Exchange.HTTP_PATH;
+    @Metadata(description = "The HTTP content encoding. Is set to provide a 
content encoding, such as `gzip`.",
+              javaType = "String")
+    public static final String CONTENT_ENCODING = Exchange.CONTENT_ENCODING;
+
     private VertxHttpConstants() {
     }
 }
diff --git 
a/components/camel-vertx/camel-vertx-http/src/main/java/org/apache/camel/component/vertx/http/VertxHttpEndpoint.java
 
b/components/camel-vertx/camel-vertx-http/src/main/java/org/apache/camel/component/vertx/http/VertxHttpEndpoint.java
index f6f02eacbda..5fa4f738435 100644
--- 
a/components/camel-vertx/camel-vertx-http/src/main/java/org/apache/camel/component/vertx/http/VertxHttpEndpoint.java
+++ 
b/components/camel-vertx/camel-vertx-http/src/main/java/org/apache/camel/component/vertx/http/VertxHttpEndpoint.java
@@ -36,7 +36,8 @@ import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.StringHelper;
 
 @UriEndpoint(firstVersion = "3.5.0", scheme = "vertx-http", title = "Vert.x 
HTTP Client", syntax = "vertx-http:httpUri",
-             category = { Category.HTTP }, producerOnly = true, 
lenientProperties = true)
+             category = { Category.HTTP }, producerOnly = true, 
lenientProperties = true,
+             headersClass = VertxHttpConstants.class)
 public class VertxHttpEndpoint extends DefaultEndpoint {
 
     @UriParam
diff --git 
a/components/camel-vertx/camel-vertx-http/src/main/java/org/apache/camel/component/vertx/http/VertxHttpHelper.java
 
b/components/camel-vertx/camel-vertx-http/src/main/java/org/apache/camel/component/vertx/http/VertxHttpHelper.java
index dec6cc13fac..842ca79ddf4 100644
--- 
a/components/camel-vertx/camel-vertx-http/src/main/java/org/apache/camel/component/vertx/http/VertxHttpHelper.java
+++ 
b/components/camel-vertx/camel-vertx-http/src/main/java/org/apache/camel/component/vertx/http/VertxHttpHelper.java
@@ -45,10 +45,10 @@ public final class VertxHttpHelper {
         Message message = exchange.getMessage();
         String queryString = (String) 
message.removeHeader(Exchange.REST_HTTP_QUERY);
         if (ObjectHelper.isEmpty(queryString)) {
-            queryString = message.getHeader(Exchange.HTTP_QUERY, String.class);
+            queryString = message.getHeader(VertxHttpConstants.HTTP_QUERY, 
String.class);
         }
 
-        String uriString = message.getHeader(Exchange.HTTP_URI, String.class);
+        String uriString = message.getHeader(VertxHttpConstants.HTTP_URI, 
String.class);
         uriString = 
exchange.getContext().resolvePropertyPlaceholders(uriString);
 
         if (uriString != null) {
@@ -68,7 +68,7 @@ public final class VertxHttpHelper {
         String uri = (String) message.removeHeader(Exchange.REST_HTTP_URI);
 
         if (ObjectHelper.isEmpty(uri)) {
-            uri = message.getHeader(Exchange.HTTP_URI, String.class);
+            uri = message.getHeader(VertxHttpConstants.HTTP_URI, String.class);
         }
 
         if (uri == null) {
@@ -79,7 +79,7 @@ public final class VertxHttpHelper {
         uri = exchange.getContext().resolvePropertyPlaceholders(uri);
 
         // Append HTTP_PATH header value if is present
-        String path = message.getHeader(Exchange.HTTP_PATH, String.class);
+        String path = message.getHeader(VertxHttpConstants.HTTP_PATH, 
String.class);
         if (ObjectHelper.isNotEmpty(path)) {
             if (path.startsWith("/")) {
                 path = path.substring(1);
@@ -138,7 +138,7 @@ public final class VertxHttpHelper {
     public static String getCharsetFromExchange(Exchange exchange) {
         String charset = null;
         if (exchange != null) {
-            String contentType = 
exchange.getMessage().getHeader(Exchange.CONTENT_TYPE, String.class);
+            String contentType = 
exchange.getMessage().getHeader(VertxHttpConstants.CONTENT_TYPE, String.class);
             charset = HttpHelper.getCharsetFromContentType(contentType);
             if (ObjectHelper.isEmpty(charset)) {
                 charset = 
exchange.getProperty(ExchangePropertyKey.CHARSET_NAME, String.class);

Reply via email to