forked from apache/camel-k
-
Notifications
You must be signed in to change notification settings - Fork 0
/
routes-rest.js
49 lines (41 loc) · 855 Bytes
/
routes-rest.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//
// To run this integrations use:
//
// 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
//
// ****************
rest()
.path('/say/hello')
.produces("text/plain")
.get().route()
.transform().constant("Hello World");
from('timer:js?period=1s')
.routeId('js')
.setBody()
.constant('Hello Camel K')
.process(proc)
.to('log:info')