-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add bindings for rest dsl in groovy/js routes #117
- Loading branch information
1 parent
994735e
commit e1312ed
Showing
2 changed files
with
81 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// | ||
// To run this integrations use: | ||
// | ||
// kamel run --name=withrest --dependency=camel:undertow runtime/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 = 8081 | ||
|
||
// **************** | ||
// | ||
// Functions | ||
// | ||
// **************** | ||
|
||
function proc(e) { | ||
e.getIn().setHeader('RandomValue', Math.floor((Math.random() * 100) + 1)) | ||
} | ||
|
||
// **************** | ||
// | ||
// Route | ||
// | ||
// **************** | ||
|
||
rest() | ||
.path('/say/hello') | ||
.get().route() | ||
.transform().constant("Hello World"); | ||
|
||
from('timer:js?period=1s') | ||
.routeId('js') | ||
.setBody() | ||
.constant('Hello Camel K') | ||
.process(proc) | ||
.to('log:info') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters