This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new ff018163bbc CAMEL-20460: Improve platform http log (#13285)
ff018163bbc is described below
commit ff018163bbc182ada10e3ca5f754c5652d0d0afc
Author: Federico Mariani <[email protected]>
AuthorDate: Sun Feb 25 08:59:13 2024 +0100
CAMEL-20460: Improve platform http log (#13285)
---
catalog/camel-report-maven-plugin/pom.xml | 6 -----
.../prometheus/MicrometerPrometheus.java | 3 ++-
.../platform/http/main/MainHttpServer.java | 18 ++++++++++----
.../src/test/resources/log4j2.properties | 28 ++++++++++++++++++++++
.../component/platform/http/HttpEndpointModel.java | 16 +++++++++++++
.../platform/http/PlatformHttpComponent.java | 4 ++--
.../platform/http/PlatformHttpConsumer.java | 3 ++-
7 files changed, 64 insertions(+), 14 deletions(-)
diff --git a/catalog/camel-report-maven-plugin/pom.xml
b/catalog/camel-report-maven-plugin/pom.xml
index d98df4c3b86..b5075eb1579 100644
--- a/catalog/camel-report-maven-plugin/pom.xml
+++ b/catalog/camel-report-maven-plugin/pom.xml
@@ -229,12 +229,6 @@
<version>${mockito-version}</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-catalog-common</artifactId>
- <version>4.5.0-SNAPSHOT</version>
- <scope>compile</scope>
- </dependency>
</dependencies>
diff --git
a/components/camel-micrometer-prometheus/src/main/java/org/apache/camel/component/micrometer/prometheus/MicrometerPrometheus.java
b/components/camel-micrometer-prometheus/src/main/java/org/apache/camel/component/micrometer/prometheus/MicrometerPrometheus.java
index 63289d4b668..3f062140fa3 100644
---
a/components/camel-micrometer-prometheus/src/main/java/org/apache/camel/component/micrometer/prometheus/MicrometerPrometheus.java
+++
b/components/camel-micrometer-prometheus/src/main/java/org/apache/camel/component/micrometer/prometheus/MicrometerPrometheus.java
@@ -385,6 +385,7 @@ public class MicrometerPrometheus extends ServiceSupport
implements CamelMetrics
// use blocking handler as the task can take longer time to complete
metrics.handler(new BlockingHandlerDecorator(handler, true));
- platformHttpComponent.addHttpEndpoint("/q/metrics", null, null);
+ platformHttpComponent.addHttpEndpoint("/q/metrics", null,
+ null, format,null);
}
}
diff --git
a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java
b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java
index 18909f9a94c..c30d2de54fb 100644
---
a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java
+++
b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java
@@ -332,6 +332,12 @@ public class MainHttpServer extends ServiceSupport
implements CamelContextAware,
if (u.getVerbs() != null) {
line += " (" + u.getVerbs() + ")";
}
+ if (u.getConsumes() != null) {
+ line += " accept: " + u.getConsumes();
+ }
+ if (u.getProduces() != null) {
+ line += " produce: " + u.getProduces();
+ }
LOG.info(" {}", line);
}
}
@@ -441,7 +447,8 @@ public class MainHttpServer extends ServiceSupport
implements CamelContextAware,
live.handler(new BlockingHandlerDecorator(handler, true));
ready.handler(new BlockingHandlerDecorator(handler, true));
- platformHttpComponent.addHttpEndpoint("/q/health", null, null);
+ platformHttpComponent.addHttpEndpoint("/q/health", null, null,
+ "application/json", null);
}
protected void setupJolokia() {
@@ -457,7 +464,8 @@ public class MainHttpServer extends ServiceSupport
implements CamelContextAware,
Handler<RoutingContext> handler = (Handler<RoutingContext>)
jolokiaPlugin.getHandler();
jolokia.handler(new BlockingHandlerDecorator(handler, true));
- platformHttpComponent.addHttpEndpoint("/q/jolokia", null, null);
+ platformHttpComponent.addHttpEndpoint("/q/jolokia", null, null,
+ "text/plain,application/json",null);
}
protected PlatformHttpPluginRegistry resolvePlatformHttpPluginRegistry() {
@@ -703,7 +711,8 @@ public class MainHttpServer extends ServiceSupport
implements CamelContextAware,
dev.handler(new BlockingHandlerDecorator(handler, true));
devSub.handler(new BlockingHandlerDecorator(handler, true));
- platformHttpComponent.addHttpEndpoint("/q/dev", null, null);
+ platformHttpComponent.addHttpEndpoint("/q/dev", null, null,
+ "text/plain,application/json", null);
}
protected void setupUploadConsole(final String dir) {
@@ -784,7 +793,8 @@ public class MainHttpServer extends ServiceSupport
implements CamelContextAware,
upload.handler(new BlockingHandlerDecorator(handler, true));
uploadDelete.handler(new BlockingHandlerDecorator(handler, true));
- platformHttpComponent.addHttpEndpoint("/q/upload", "PUT,DELETE", null);
+ platformHttpComponent.addHttpEndpoint("/q/upload", "PUT,DELETE",
+ "multipart/form-data", null, null);
}
}
diff --git
a/components/camel-platform-http-main/src/test/resources/log4j2.properties
b/components/camel-platform-http-main/src/test/resources/log4j2.properties
new file mode 100644
index 00000000000..ae537af0b48
--- /dev/null
+++ b/components/camel-platform-http-main/src/test/resources/log4j2.properties
@@ -0,0 +1,28 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+appender.file.type = File
+appender.file.name = file
+appender.file.fileName = target/camel-platform-http-main-test.log
+appender.file.layout.type = PatternLayout
+appender.file.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n
+appender.out.type = Console
+appender.out.name = out
+appender.out.layout.type = PatternLayout
+appender.out.layout.pattern = [%30.30t] %-30.30c{1} %-5p %m%n
+
+rootLogger.level = INFO
+rootLogger.appenderRef.file.ref = file
\ No newline at end of file
diff --git
a/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/HttpEndpointModel.java
b/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/HttpEndpointModel.java
index ab2c5061167..0e75f19ead6 100644
---
a/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/HttpEndpointModel.java
+++
b/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/HttpEndpointModel.java
@@ -29,6 +29,8 @@ public class HttpEndpointModel implements
Comparable<HttpEndpointModel> {
private final String uri;
private String verbs;
+ private final String consumes;
+ private final String produces;
private final Consumer consumer;
public HttpEndpointModel(String uri) {
@@ -40,9 +42,15 @@ public class HttpEndpointModel implements
Comparable<HttpEndpointModel> {
}
public HttpEndpointModel(String uri, String verbs, Consumer consumer) {
+ this(uri, verbs, null, null, consumer);
+ }
+
+ public HttpEndpointModel(String uri, String verbs, String consumes, String
produces, Consumer consumer) {
this.uri = uri;
addVerb(verbs);
this.consumer = consumer;
+ this.consumes = consumes;
+ this.produces = produces;
}
public String getUri() {
@@ -71,6 +79,14 @@ public class HttpEndpointModel implements
Comparable<HttpEndpointModel> {
}
}
+ public String getConsumes() {
+ return consumes;
+ }
+
+ public String getProduces() {
+ return produces;
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) {
diff --git
a/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/PlatformHttpComponent.java
b/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/PlatformHttpComponent.java
index 72bbd3f91e8..e6293abeff3 100644
---
a/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/PlatformHttpComponent.java
+++
b/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/PlatformHttpComponent.java
@@ -103,8 +103,8 @@ public class PlatformHttpComponent extends DefaultComponent
implements RestConsu
/**
* Adds a known http endpoint managed by this component.
*/
- public void addHttpEndpoint(String uri, String verbs, Consumer consumer) {
- HttpEndpointModel model = new HttpEndpointModel(uri, verbs, consumer);
+ public void addHttpEndpoint(String uri, String verbs, String consumes,
String produces, Consumer consumer) {
+ HttpEndpointModel model = new HttpEndpointModel(uri, verbs, consumes,
produces, consumer);
httpEndpoints.add(model);
for (PlatformHttpListener listener : listeners) {
try {
diff --git
a/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/PlatformHttpConsumer.java
b/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/PlatformHttpConsumer.java
index 3cd204e19be..5fb01bf62f1 100644
---
a/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/PlatformHttpConsumer.java
+++
b/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/PlatformHttpConsumer.java
@@ -51,7 +51,8 @@ public class PlatformHttpConsumer extends DefaultConsumer
implements Suspendable
protected void doStart() throws Exception {
super.doStart();
ServiceHelper.startService(delegatedConsumer);
- getComponent().addHttpEndpoint(getEndpoint().getPath(),
getEndpoint().getHttpMethodRestrict(), delegatedConsumer);
+ getComponent().addHttpEndpoint(getEndpoint().getPath(),
getEndpoint().getHttpMethodRestrict(),
+ getEndpoint().getConsumes(), getEndpoint().getProduces(),
delegatedConsumer);
}
@Override