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

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


The following commit(s) were added to refs/heads/master by this push:
     new 71557bd  chore(js): fix examples, use arrow function for lambda style 
processor
71557bd is described below

commit 71557bd5d2ce55544fc0b677f9ac4681d985761b
Author: lburgazzoli <lburgazz...@gmail.com>
AuthorDate: Thu Jul 25 08:49:13 2019 +0200

    chore(js): fix examples, use arrow function for lambda style processor
---
 examples/routes-rest.js | 45 +++++++++------------------------------------
 examples/routes.js      | 36 +++++++++++-------------------------
 2 files changed, 20 insertions(+), 61 deletions(-)

diff --git a/examples/routes-rest.js b/examples/routes-rest.js
index 71c6c91..0cd6595 100644
--- a/examples/routes-rest.js
+++ b/examples/routes-rest.js
@@ -16,49 +16,22 @@
 //
 // To run this integrations use:
 //
-//     kamel run --name=withrest --dependency=camel-rest 
--dependency=camel-undertow examples/routes-rest.js
+//     kamel run --name=withrest --dependency=camel-undertow 
examples/routes-rest.js
 //
 
-// ****************
-//
-// Setup
-//
-// ****************
-
-l = components.get('log')
-l.exchangeFormatter = function(e) {
-    return "log - body=" + e.in.body + ", headers=" + e.in.headers
-}
-
-c = restConfiguration()
-c.component = 'undertow'
-c.port = 8080
-
-// ****************
-//
-// Functions
-//
-// ****************
-
-function proc(e) {
-    e.getIn().setHeader('RandomValue', Math.floor((Math.random() * 100) + 1))
-}
-
-// ****************
-//
-// Route
-//
-// ****************
+c = restConfiguration();
+c.setComponent('undertow');
+c.setPort('8080');
 
-rest()
-    .path('/say/hello')
+rest('/say/hello')
     .produces("text/plain")
-    .get().route()
+    .get()
+        .route()
         .transform().constant("Hello World");
 
 from('timer:js?period=1s')
     .routeId('js')
     .setBody()
         .constant('Hello Camel K')
-    .process(proc)
-    .to('log:info')
+    .process(e => e.getIn().setHeader('RandomValue', Math.floor((Math.random() 
* 100) + 1)))
+    .to('log:info?showHeaders=true')
diff --git a/examples/routes.js b/examples/routes.js
index 672faee..2484434 100644
--- a/examples/routes.js
+++ b/examples/routes.js
@@ -13,36 +13,22 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-// ****************
 //
-// Setup
+// To run this integrations use:
 //
-// ****************
-
-//l = components.get('log')
-//l.exchangeFormatter = function(e) {
-//    return "log - body=" + e.in.body + ", headers=" + e.in.headers
-//}
-
-// ****************
-//
-// Functions
+//     kamel run examples/routes.js
 //
-// ****************
 
-function proc(e) {
-    e.getIn().setHeader('RandomValue', Math.floor((Math.random() * 100) + 1))
-}
-
-// ****************
-//
-// Route
-//
-// ****************
+l = components.get('log');
+l.setExchangeFormatter(e => {
+    return "body=" + e.getIn().getBody() + ", headers=" + 
e.getIn().getHeaders()
+})
 
 from('timer:js?period=1s')
     .routeId('js')
     .setBody()
-        .constant('Hello Camel K')
-    .process(proc)
-    .to('log:info')
\ No newline at end of file
+        .simple('Hello Camel K')
+    .process(e => {
+        e.getIn().setHeader('RandomValue', Math.floor((Math.random() * 100) + 
1))
+    })
+    .to('log:info');
\ No newline at end of file

Reply via email to