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 2020/02/15 13:13:22 UTC

[camel] branch master updated: CAMEL-14565: camel-webhook refactor a bit and add docs for missing option.

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.git


The following commit(s) were added to refs/heads/master by this push:
     new f9d9e49  CAMEL-14565: camel-webhook refactor a bit and add docs for missing option.
f9d9e49 is described below

commit f9d9e49554a4ffa9d3c3eee7b7a8ae0a5ffaf765
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat Feb 15 14:12:34 2020 +0100

    CAMEL-14565: camel-webhook refactor a bit and add docs for missing option.
---
 .../webhook/WebhookEndpointConfigurer.java         |   4 +-
 .../apache/camel/component/webhook/webhook.json    |  12 +--
 .../src/main/docs/webhook-component.adoc           |  12 +--
 .../camel/component/webhook/MultiRestConsumer.java |   5 +-
 .../camel/component/webhook/WebhookComponent.java  |  66 +++++++++++-
 .../component/webhook/WebhookConfiguration.java    | 117 +++------------------
 .../camel/component/webhook/WebhookEndpoint.java   |  11 +-
 .../component/webhook/WebhookBasePathTest.java     |   2 +-
 .../component/webhook/WebhookHttpBindingTest.java  |   4 +-
 .../component/webhook/WebhookMultiRouteTest.java   |   4 +-
 10 files changed, 107 insertions(+), 130 deletions(-)

diff --git a/components/camel-webhook/src/generated/java/org/apache/camel/component/webhook/WebhookEndpointConfigurer.java b/components/camel-webhook/src/generated/java/org/apache/camel/component/webhook/WebhookEndpointConfigurer.java
index da82aee..5296e44 100644
--- a/components/camel-webhook/src/generated/java/org/apache/camel/component/webhook/WebhookEndpointConfigurer.java
+++ b/components/camel-webhook/src/generated/java/org/apache/camel/component/webhook/WebhookEndpointConfigurer.java
@@ -15,6 +15,8 @@ public class WebhookEndpointConfigurer extends PropertyConfigurerSupport impleme
     public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) {
         WebhookEndpoint target = (WebhookEndpoint) obj;
         switch (ignoreCase ? name.toLowerCase() : name) {
+        case "bridgeerrorhandler":
+        case "bridgeErrorHandler": target.setBridgeErrorHandler(property(camelContext, boolean.class, value)); return true;
         case "webhookautoregister":
         case "webhookAutoRegister": target.getConfiguration().setWebhookAutoRegister(property(camelContext, boolean.class, value)); return true;
         case "webhookbasepath":
@@ -25,8 +27,6 @@ public class WebhookEndpointConfigurer extends PropertyConfigurerSupport impleme
         case "webhookExternalUrl": target.getConfiguration().setWebhookExternalUrl(property(camelContext, java.lang.String.class, value)); return true;
         case "webhookpath":
         case "webhookPath": target.getConfiguration().setWebhookPath(property(camelContext, java.lang.String.class, value)); return true;
-        case "bridgeerrorhandler":
-        case "bridgeErrorHandler": target.setBridgeErrorHandler(property(camelContext, boolean.class, value)); return true;
         case "exceptionhandler":
         case "exceptionHandler": target.setExceptionHandler(property(camelContext, org.apache.camel.spi.ExceptionHandler.class, value)); return true;
         case "exchangepattern":
diff --git a/components/camel-webhook/src/generated/resources/org/apache/camel/component/webhook/webhook.json b/components/camel-webhook/src/generated/resources/org/apache/camel/component/webhook/webhook.json
index 81c9378..84f2adf 100644
--- a/components/camel-webhook/src/generated/resources/org/apache/camel/component/webhook/webhook.json
+++ b/components/camel-webhook/src/generated/resources/org/apache/camel/component/webhook/webhook.json
@@ -24,13 +24,13 @@
     "configuration": { "kind": "property", "displayName": "Configuration", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.webhook.WebhookConfiguration", "deprecated": false, "secret": false, "description": "Set the default configuration for the webhook meta-component." }
   },
   "properties": {
-    "endpointUri": { "kind": "path", "displayName": "Endpoint Uri", "group": "consumer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.webhook.WebhookConfiguration", "configurationField": "configuration", "description": "The delegate uri. Must belong to a component that supports webhooks." },
-    "webhookAutoRegister": { "kind": "parameter", "displayName": "Webhook Auto Register", "group": "common", "label": "common", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": "true", "configurationClass": "org.apache.camel.component.webhook.WebhookConfiguration", "configurationField": "configuration", "description": "Automatically register the webhook at startup and unregister it on shutdown." },
-    "webhookBasePath": { "kind": "parameter", "displayName": "Webhook Base Path", "group": "common", "label": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.webhook.WebhookConfiguration", "configurationField": "configuration", "description": "The first (base) path element where the webhook will be exposed. It's a good practice to set it to a random string, so that it ca [...]
-    "webhookComponentName": { "kind": "parameter", "displayName": "Webhook Component Name", "group": "common", "label": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.webhook.WebhookConfiguration", "configurationField": "configuration", "description": "The Camel Rest component to use for the REST transport, such as netty-http." },
-    "webhookExternalUrl": { "kind": "parameter", "displayName": "Webhook External Url", "group": "common", "label": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.webhook.WebhookConfiguration", "configurationField": "configuration", "description": "The URL of the current service as seen by the webhook provider" },
-    "webhookPath": { "kind": "parameter", "displayName": "Webhook Path", "group": "common", "label": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.webhook.WebhookConfiguration", "configurationField": "configuration", "description": "The path where the webhook endpoint will be exposed (relative to basePath, if any)" },
+    "endpointUri": { "kind": "path", "displayName": "Endpoint Uri", "group": "consumer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "secret": false, "configurationClass": "org.apache.camel.component.webhook.WebhookConfiguration", "configurationField": "configuration", "description": "The delegate uri. Must belong to a component that supports webhooks." },
     "bridgeErrorHandler": { "kind": "parameter", "displayName": "Bridge Error Handler", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled b [...]
+    "webhookAutoRegister": { "kind": "parameter", "displayName": "Webhook Auto Register", "group": "consumer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": "true", "configurationClass": "org.apache.camel.component.webhook.WebhookConfiguration", "configurationField": "configuration", "description": "Automatically register the webhook at startup and unregister it on shutdown." },
+    "webhookBasePath": { "kind": "parameter", "displayName": "Webhook Base Path", "group": "consumer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.webhook.WebhookConfiguration", "configurationField": "configuration", "description": "The first (base) path element where the webhook will be exposed. It's a good practice to set it to a random string, so that it cannot [...]
+    "webhookComponentName": { "kind": "parameter", "displayName": "Webhook Component Name", "group": "consumer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.webhook.WebhookConfiguration", "configurationField": "configuration", "description": "The Camel Rest component to use for the REST transport, such as netty-http." },
+    "webhookExternalUrl": { "kind": "parameter", "displayName": "Webhook External Url", "group": "consumer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.webhook.WebhookConfiguration", "configurationField": "configuration", "description": "The URL of the current service as seen by the webhook provider" },
+    "webhookPath": { "kind": "parameter", "displayName": "Webhook Path", "group": "consumer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.webhook.WebhookConfiguration", "configurationField": "configuration", "description": "The path where the webhook endpoint will be exposed (relative to basePath, if any)" },
     "exceptionHandler": { "kind": "parameter", "displayName": "Exception Handler", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.spi.ExceptionHandler", "optionalPrefix": "consumer.", "deprecated": false, "secret": false, "description": "To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with [...]
     "exchangePattern": { "kind": "parameter", "displayName": "Exchange Pattern", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.ExchangePattern", "enum": [ "InOnly", "InOut", "InOptionalOut" ], "deprecated": false, "secret": false, "description": "Sets the exchange pattern when the consumer creates an exchange." },
     "basicPropertyBinding": { "kind": "parameter", "displayName": "Basic Property Binding", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "Whether the endpoint should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities" },
diff --git a/components/camel-webhook/src/main/docs/webhook-component.adoc b/components/camel-webhook/src/main/docs/webhook-component.adoc
index 61867f3..0094964 100644
--- a/components/camel-webhook/src/main/docs/webhook-component.adoc
+++ b/components/camel-webhook/src/main/docs/webhook-component.adoc
@@ -69,7 +69,7 @@ with the following path and query parameters:
 [width="100%",cols="2,5,^1,2",options="header"]
 |===
 | Name | Description | Default | Type
-| *endpointUri* | The delegate uri. Must belong to a component that supports webhooks. |  | String
+| *endpointUri* | *Required* The delegate uri. Must belong to a component that supports webhooks. |  | String
 |===
 
 
@@ -79,12 +79,12 @@ with the following path and query parameters:
 [width="100%",cols="2,5,^1,2",options="header"]
 |===
 | Name | Description | Default | Type
-| *webhookAutoRegister* (common) | Automatically register the webhook at startup and unregister it on shutdown. | true | boolean
-| *webhookBasePath* (common) | The first (base) path element where the webhook will be exposed. It's a good practice to set it to a random string, so that it cannot be guessed by unauthorized parties. |  | String
-| *webhookComponentName* (common) | The Camel Rest component to use for the REST transport, such as netty-http. |  | String
-| *webhookExternalUrl* (common) | The URL of the current service as seen by the webhook provider |  | String
-| *webhookPath* (common) | The path where the webhook endpoint will be exposed (relative to basePath, if any) |  | String
 | *bridgeErrorHandler* (consumer) | Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | boolean
+| *webhookAutoRegister* (consumer) | Automatically register the webhook at startup and unregister it on shutdown. | true | boolean
+| *webhookBasePath* (consumer) | The first (base) path element where the webhook will be exposed. It's a good practice to set it to a random string, so that it cannot be guessed by unauthorized parties. |  | String
+| *webhookComponentName* (consumer) | The Camel Rest component to use for the REST transport, such as netty-http. |  | String
+| *webhookExternalUrl* (consumer) | The URL of the current service as seen by the webhook provider |  | String
+| *webhookPath* (consumer) | The path where the webhook endpoint will be exposed (relative to basePath, if any) |  | String
 | *exceptionHandler* (consumer) | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored. |  | ExceptionHandler
 | *exchangePattern* (consumer) | Sets the exchange pattern when the consumer creates an exchange. The value can be one of: InOnly, InOut, InOptionalOut |  | ExchangePattern
 | *basicPropertyBinding* (advanced) | Whether the endpoint should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | boolean
diff --git a/components/camel-webhook/src/main/java/org/apache/camel/component/webhook/MultiRestConsumer.java b/components/camel-webhook/src/main/java/org/apache/camel/component/webhook/MultiRestConsumer.java
index 42505c4..35ef1cf 100644
--- a/components/camel-webhook/src/main/java/org/apache/camel/component/webhook/MultiRestConsumer.java
+++ b/components/camel-webhook/src/main/java/org/apache/camel/component/webhook/MultiRestConsumer.java
@@ -49,7 +49,6 @@ public class MultiRestConsumer extends DefaultConsumer {
                     null, null, null, config, Collections.emptyMap());
             configurer.configure(consumer);
 
-
             context.getRestRegistry().addRestService(consumer, url, url, path, null, method,
                     null, null, null, null, null, null);
 
@@ -74,18 +73,18 @@ public class MultiRestConsumer extends DefaultConsumer {
 
     @Override
     public void doStop() throws Exception {
-        super.doStop();
         for (Consumer consumer : this.delegateConsumers) {
             ServiceHelper.stopService(consumer);
         }
+        super.doStop();
     }
 
     @Override
     protected void doShutdown() throws Exception {
-        super.doShutdown();
         for (Consumer consumer : this.delegateConsumers) {
             ServiceHelper.stopAndShutdownService(consumer);
         }
+        super.doShutdown();
     }
 
     @FunctionalInterface
diff --git a/components/camel-webhook/src/main/java/org/apache/camel/component/webhook/WebhookComponent.java b/components/camel-webhook/src/main/java/org/apache/camel/component/webhook/WebhookComponent.java
index ffed773..aff4fd7 100644
--- a/components/camel-webhook/src/main/java/org/apache/camel/component/webhook/WebhookComponent.java
+++ b/components/camel-webhook/src/main/java/org/apache/camel/component/webhook/WebhookComponent.java
@@ -17,14 +17,21 @@
 package org.apache.camel.component.webhook;
 
 import java.net.URISyntaxException;
+import java.net.UnknownHostException;
+import java.nio.charset.StandardCharsets;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.Base64;
 import java.util.Map;
 import java.util.stream.Collectors;
 
 import org.apache.camel.Endpoint;
+import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.RestConfiguration;
 import org.apache.camel.spi.annotations.Component;
 import org.apache.camel.support.DefaultComponent;
+import org.apache.camel.util.HostUtils;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.URISupport;
 
@@ -48,7 +55,9 @@ public class WebhookComponent extends DefaultComponent {
         }
 
         WebhookConfiguration config = configuration != null ? configuration.copy() : new WebhookConfiguration();
-        WebhookEndpoint endpoint = new WebhookEndpoint(uri, this, config);
+        RestConfiguration restConfig = getCamelContext().getRestConfiguration(config.getWebhookComponentName(), true);
+
+        WebhookEndpoint endpoint = new WebhookEndpoint(uri, this, config, restConfig);
         setProperties(endpoint, parameters);
         // we need to apply the params here
         if (parameters != null && !parameters.isEmpty()) {
@@ -56,9 +65,6 @@ public class WebhookComponent extends DefaultComponent {
         }
         endpoint.getConfiguration().setEndpointUri(delegateUri);
 
-        RestConfiguration restConfig = getCamelContext().getRestConfiguration(config.getWebhookComponentName(), true);
-        config.setRestConfiguration(restConfig);
-
         return endpoint;
     }
 
@@ -89,4 +95,56 @@ public class WebhookComponent extends DefaultComponent {
         this.configuration = configuration;
     }
 
+    /**
+     * Computes the URL of the webhook that should be used to bind the REST endpoint locally.
+     */
+    public static String computeServerUriPrefix(RestConfiguration restConfiguration) throws UnknownHostException {
+        // if no explicit port/host configured, then use port from rest configuration
+        String scheme = "http";
+        String host = "";
+        int port = 80;
+
+        if (restConfiguration.getScheme() != null) {
+            scheme = restConfiguration.getScheme();
+        }
+        if (restConfiguration.getHost() != null) {
+            host = restConfiguration.getHost();
+        }
+        int num = restConfiguration.getPort();
+        if (num > 0) {
+            port = num;
+        }
+
+        // if no explicit hostname set then resolve the hostname
+        if (ObjectHelper.isEmpty(host)) {
+            if (restConfiguration.getHostNameResolver() == RestConfiguration.RestHostNameResolver.allLocalIp) {
+                host = "0.0.0.0";
+            } else if (restConfiguration.getHostNameResolver() == RestConfiguration.RestHostNameResolver.localHostName) {
+                host = HostUtils.getLocalHostName();
+            } else if (restConfiguration.getHostNameResolver() == RestConfiguration.RestHostNameResolver.localIp) {
+                host = HostUtils.getLocalIp();
+            }
+        }
+
+        return scheme + "://" + host + (port != 80 ? ":" + port : "");
+    }
+
+    /**
+     * A default path is computed for the webhook if not provided by the user.
+     * It uses a hash of the delegate endpoint in order for it to be reproducible.
+     *
+     * This is not random on purpose.
+     */
+    public static String computeDefaultPath(String uri) {
+        try {
+            MessageDigest md = MessageDigest.getInstance("SHA-256");
+            md.update(uri.getBytes(StandardCharsets.UTF_8));
+            byte[] digest = md.digest();
+
+            return "/" + Base64.getUrlEncoder().encodeToString(digest);
+        } catch (NoSuchAlgorithmException e) {
+            throw new RuntimeCamelException("Cannot compute default webhook path", e);
+        }
+    }
+
 }
diff --git a/components/camel-webhook/src/main/java/org/apache/camel/component/webhook/WebhookConfiguration.java b/components/camel-webhook/src/main/java/org/apache/camel/component/webhook/WebhookConfiguration.java
index be3a58c..35c1efe 100644
--- a/components/camel-webhook/src/main/java/org/apache/camel/component/webhook/WebhookConfiguration.java
+++ b/components/camel-webhook/src/main/java/org/apache/camel/component/webhook/WebhookConfiguration.java
@@ -16,19 +16,12 @@
  */
 package org.apache.camel.component.webhook;
 
-import java.net.UnknownHostException;
-import java.nio.charset.StandardCharsets;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.util.Base64;
-
 import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.RestConfiguration;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriParams;
 import org.apache.camel.spi.UriPath;
-import org.apache.camel.util.HostUtils;
-import org.apache.camel.util.ObjectHelper;
 
 /**
  * Configuration class for the webhook component.
@@ -40,26 +33,24 @@ public class WebhookConfiguration implements Cloneable {
      * Note: all properties start with the 'webhook' prefix to avoid collision with the delegate endpoint.
      */
 
-    @UriParam(label = "common")
+    @UriPath @Metadata(required = true)
+    private String endpointUri;
+
+    @UriParam
     private String webhookComponentName;
 
-    @UriParam(label = "common")
+    @UriParam
     private String webhookExternalUrl;
 
-    @UriParam(label = "common")
+    @UriParam
     private String webhookBasePath;
 
-    @UriParam(label = "common")
+    @UriParam
     private String webhookPath;
 
-    @UriParam(label = "common", defaultValue = "true")
+    @UriParam(defaultValue = "true")
     private boolean webhookAutoRegister = true;
 
-    @UriPath
-    private String endpointUri;
-
-    private RestConfiguration restConfiguration;
-
     public WebhookConfiguration() {
     }
 
@@ -79,71 +70,26 @@ public class WebhookConfiguration implements Cloneable {
     }
 
     /**
-     * Computes the external URL of the webhook as seen by the remote webhook provider.
-     */
-    public String computeFullExternalUrl() throws UnknownHostException {
-        String externalServerUrl = this.webhookExternalUrl;
-        if (externalServerUrl == null) {
-            externalServerUrl = computeServerUriPrefix();
-        }
-        String path = computeFullPath(true);
-        return externalServerUrl + path;
-    }
-
-    /**
-     * Computes the URL of the webhook that should be used to bind the REST endpoint locally.
-     */
-    public String computeServerUriPrefix() throws UnknownHostException {
-        // if no explicit port/host configured, then use port from rest configuration
-        String scheme = "http";
-        String host = "";
-        int port = 80;
-
-        if (restConfiguration.getScheme() != null) {
-            scheme = restConfiguration.getScheme();
-        }
-        if (restConfiguration.getHost() != null) {
-            host = restConfiguration.getHost();
-        }
-        int num = restConfiguration.getPort();
-        if (num > 0) {
-            port = num;
-        }
-
-        // if no explicit hostname set then resolve the hostname
-        if (ObjectHelper.isEmpty(host)) {
-            if (restConfiguration.getHostNameResolver() == RestConfiguration.RestHostNameResolver.allLocalIp) {
-                host = "0.0.0.0";
-            } else if (restConfiguration.getHostNameResolver() == RestConfiguration.RestHostNameResolver.localHostName) {
-                host = HostUtils.getLocalHostName();
-            } else if (restConfiguration.getHostNameResolver() == RestConfiguration.RestHostNameResolver.localIp) {
-                host = HostUtils.getLocalIp();
-            }
-        }
-
-        return scheme + "://" + host + (port != 80 ? ":" + port : "");
-    }
-
-    /**
      * Computes the path part of the webhook.
      *
+     * @param restConfiguration rest configuration
      * @param external indicates if it's the path seen by the external provider or the internal one.
      * @return the webhook full path
      */
-    public String computeFullPath(boolean external) {
+    public String computeFullPath(RestConfiguration restConfiguration, boolean external) {
         // calculate the url to the rest service
-        String path = this.webhookPath;
+        String path = webhookPath;
         if (path == null) {
-            path = computeDefaultPath(getEndpointUri());
+            path = WebhookComponent.computeDefaultPath(endpointUri);
         } else if (!path.startsWith("/")) {
             path = "/" + path;
         }
 
-        if (this.webhookBasePath != null) {
-            if (!this.webhookBasePath.startsWith("/")) {
-                path = "/" + this.webhookBasePath + path;
+        if (webhookBasePath != null) {
+            if (!webhookBasePath.startsWith("/")) {
+                path = "/" + webhookBasePath + path;
             } else {
-                path = this.webhookBasePath + path;
+                path = webhookBasePath + path;
             }
         }
 
@@ -161,24 +107,6 @@ public class WebhookConfiguration implements Cloneable {
         return path;
     }
 
-    /**
-     * A default path is computed for the webhook if not provided by the user.
-     * It uses a hash of the delegate endpoint in order for it to be reproducible.
-     *
-     * This is not random on purpose.
-     */
-    protected static String computeDefaultPath(String uri) {
-        try {
-            MessageDigest md = MessageDigest.getInstance("SHA-256");
-            md.update(uri.getBytes(StandardCharsets.UTF_8));
-            byte[] digest = md.digest();
-
-            return "/" + Base64.getUrlEncoder().encodeToString(digest);
-        } catch (NoSuchAlgorithmException e) {
-            throw new RuntimeCamelException("Cannot compute default webhook path", e);
-        }
-    }
-
     public String getEndpointUri() {
         return endpointUri;
     }
@@ -190,17 +118,6 @@ public class WebhookConfiguration implements Cloneable {
         this.endpointUri = endpointUri;
     }
 
-    public RestConfiguration getRestConfiguration() {
-        return restConfiguration;
-    }
-
-    /**
-     * The Camel Rest Configuration used by the webhook.
-     */
-    public void setRestConfiguration(RestConfiguration restConfiguration) {
-        this.restConfiguration = restConfiguration;
-    }
-
     /**
      * The Camel Rest component to use for the REST transport, such as netty-http.
      */
diff --git a/components/camel-webhook/src/main/java/org/apache/camel/component/webhook/WebhookEndpoint.java b/components/camel-webhook/src/main/java/org/apache/camel/component/webhook/WebhookEndpoint.java
index dd10b36..7f7ba62 100644
--- a/components/camel-webhook/src/main/java/org/apache/camel/component/webhook/WebhookEndpoint.java
+++ b/components/camel-webhook/src/main/java/org/apache/camel/component/webhook/WebhookEndpoint.java
@@ -23,6 +23,7 @@ import org.apache.camel.DelegateEndpoint;
 import org.apache.camel.Endpoint;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
+import org.apache.camel.spi.RestConfiguration;
 import org.apache.camel.spi.RestConsumerFactory;
 import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
@@ -40,13 +41,15 @@ public class WebhookEndpoint extends DefaultEndpoint implements DelegateEndpoint
     private static final Logger LOG = LoggerFactory.getLogger(WebhookEndpoint.class);
 
     private WebhookCapableEndpoint delegateEndpoint;
+    private RestConfiguration restConfiguration;
 
     @UriParam(label = "advanced")
     private WebhookConfiguration configuration;
 
-    public WebhookEndpoint(String uri, WebhookComponent component, WebhookConfiguration configuration) {
+    public WebhookEndpoint(String uri, WebhookComponent component, WebhookConfiguration configuration, RestConfiguration restConfiguration) {
         super(uri, component);
         this.configuration = configuration;
+        this.restConfiguration = restConfiguration;
     }
 
     @Override
@@ -58,14 +61,14 @@ public class WebhookEndpoint extends DefaultEndpoint implements DelegateEndpoint
     public Consumer createConsumer(Processor processor) throws Exception {
         RestConsumerFactory factory = WebhookUtils.locateRestConsumerFactory(getCamelContext(), configuration);
 
-        String path = configuration.computeFullPath(false);
-        String serverUrl = configuration.computeServerUriPrefix();
+        String path = configuration.computeFullPath(restConfiguration, false);
+        String serverUrl = WebhookComponent.computeServerUriPrefix(restConfiguration);
         String url = serverUrl + path;
 
         Processor handler = delegateEndpoint.createWebhookHandler(processor);
 
         return new MultiRestConsumer(getCamelContext(), factory, this, handler, delegateEndpoint.getWebhookMethods(), url, path,
-                configuration.getRestConfiguration(), this::configureConsumer);
+                restConfiguration, this::configureConsumer);
     }
 
     @Override
diff --git a/components/camel-webhook/src/test/java/org/apache/camel/component/webhook/WebhookBasePathTest.java b/components/camel-webhook/src/test/java/org/apache/camel/component/webhook/WebhookBasePathTest.java
index ec7da63..35c351e 100644
--- a/components/camel-webhook/src/test/java/org/apache/camel/component/webhook/WebhookBasePathTest.java
+++ b/components/camel-webhook/src/test/java/org/apache/camel/component/webhook/WebhookBasePathTest.java
@@ -41,7 +41,7 @@ public class WebhookBasePathTest extends WebhookTestBase {
     @Test
     public void testAutoPath() {
         String result = template.requestBody("netty-http:http://localhost:" + port + "/base"
-                + WebhookConfiguration.computeDefaultPath("wb-delegate://auto"), "", String.class);
+                + WebhookComponent.computeDefaultPath("wb-delegate://auto"), "", String.class);
         assertEquals("auto: webhook", result);
     }
 
diff --git a/components/camel-webhook/src/test/java/org/apache/camel/component/webhook/WebhookHttpBindingTest.java b/components/camel-webhook/src/test/java/org/apache/camel/component/webhook/WebhookHttpBindingTest.java
index 8e42d21..e91b1d8 100644
--- a/components/camel-webhook/src/test/java/org/apache/camel/component/webhook/WebhookHttpBindingTest.java
+++ b/components/camel-webhook/src/test/java/org/apache/camel/component/webhook/WebhookHttpBindingTest.java
@@ -31,11 +31,11 @@ public class WebhookHttpBindingTest extends WebhookTestBase {
     @Test
     public void testWrapper() {
         String result = template.requestBody("netty-http:http://localhost:" + port
-                + WebhookConfiguration.computeDefaultPath("wb-delegate://xx"), "", String.class);
+                + WebhookComponent.computeDefaultPath("wb-delegate://xx"), "", String.class);
         assertEquals("msg: webhook", result);
 
         result = template.requestBodyAndHeader("netty-http:http://localhost:" + port
-                + WebhookConfiguration.computeDefaultPath("wb-delegate://xx"), "", Exchange.HTTP_METHOD, "PUT", String.class);
+                + WebhookComponent.computeDefaultPath("wb-delegate://xx"), "", Exchange.HTTP_METHOD, "PUT", String.class);
         assertEquals("msg: webhook", result);
     }
 
diff --git a/components/camel-webhook/src/test/java/org/apache/camel/component/webhook/WebhookMultiRouteTest.java b/components/camel-webhook/src/test/java/org/apache/camel/component/webhook/WebhookMultiRouteTest.java
index 5a0b0c3..1a43bab 100644
--- a/components/camel-webhook/src/test/java/org/apache/camel/component/webhook/WebhookMultiRouteTest.java
+++ b/components/camel-webhook/src/test/java/org/apache/camel/component/webhook/WebhookMultiRouteTest.java
@@ -27,11 +27,11 @@ public class WebhookMultiRouteTest extends WebhookTestBase {
     @Test
     public void testMultiRoute() {
         String result = template.requestBody("netty-http:http://localhost:" + port
-                + WebhookConfiguration.computeDefaultPath("wb-delegate://yy"), "", String.class);
+                + WebhookComponent.computeDefaultPath("wb-delegate://yy"), "", String.class);
         assertEquals("uri: webhook", result);
 
         result = template.requestBody("netty-http:http://localhost:" + port
-                + WebhookConfiguration.computeDefaultPath("wb-delegate://xx"), "", String.class);
+                + WebhookComponent.computeDefaultPath("wb-delegate://xx"), "", String.class);
         assertEquals("msg: webhook", result);
     }