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 acedbe9243a CAMEL-17333: camel-console - Output json as response.
acedbe9243a is described below
commit acedbe9243a86a5adc43984e1c61e39213b34dfd
Author: Claus Ibsen <[email protected]>
AuthorDate: Sun May 29 11:23:48 2022 +0200
CAMEL-17333: camel-console - Output json as response.
---
.../modules/ROOT/pages/camel-console.adoc | 28 ++++++++++++++++------
1 file changed, 21 insertions(+), 7 deletions(-)
diff --git a/docs/user-manual/modules/ROOT/pages/camel-console.adoc
b/docs/user-manual/modules/ROOT/pages/camel-console.adoc
index c7e1fb84f08..a3d04ec5a2c 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-console.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-console.adoc
@@ -55,12 +55,23 @@ public class FooConsole extends AbstractDevConsole {
}
@Override
- protected Object doCall(MediaType mediaType, Map<String, Object> options) {
- if (mediaType.TEXT.equals(mediaType)) {
- return "Some foolish text here";
- } else {
- // json structure
- }
+ protected String doCallText(Map<String, Object> options) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("Hello from my custom console");
+
+ // more stuff here
+
+ return sb.toString();
+ }
+
+ @Override
+ protected JsonObject doCallJson(Map<String, Object> options) {
+ JsonObject root = new JsonObject();
+ root.put("message", "Hello from my custom console");
+
+ // more stuff here
+
+ return root;
}
}
@@ -69,7 +80,10 @@ public class FooConsole extends AbstractDevConsole {
The class must be annotated with `DevConsole` and the unique id of the console
(must be unique across all consoles).
In the constructor the console specifies which group, id, display title, and
description to use.
-The `doCall` method is responsible for gathering the information the console
should output.
+The `doCallText` and `doCallJson` methods is responsible for gathering the
information the console should output.
+
+If the console does not support either text or json output, then the methods
can return `null`,
+and override the `supportMediaType` method and return `true` for the
media-type that are supported.
=== Supported Media Types