hguerrero commented on issue #1035: can't use a function processor with 
javascript
URL: https://github.com/apache/camel-k/issues/1035#issuecomment-548158195
 
 
   changed to wrapper, no crash but now looks like function is not updating the 
body
   
   ```
   const Processor = Java.type("org.apache.camel.Processor");
   const p = Java.extend(Processor);
   const proc = new p(processInventory);
   
   c = restConfiguration();
   c.setComponent('undertow');
   c.setPort('8080');
   
   rest('/')
       .post('/notify/order')
       .to('direct:notify');
   
   from('direct:notify')
       .log('Inventory Notified ${body}')
       .process(proc)
       .to('log:info');
   
   function processInventory(e) {
       return JSON.stringify({
           inventoryId: '12345'
       })
   }
   ```
   called `curl -X POST 
http://inventory-myproject.192.168.99.106.nip.io/notify/order -v`
   
   returned: 
   
   ```
   *   Trying 192.168.99.106...
   * TCP_NODELAY set
   * Connected to inventory-myproject.192.168.99.106.nip.io (192.168.99.106) 
port 80 (#0)
   > POST /notify/order HTTP/1.1
   > Host: inventory-myproject.192.168.99.106.nip.io
   > User-Agent: curl/7.54.0
   > Accept: */*
   > 
   < HTTP/1.1 200 OK
   < Accept: */*
   < User-Agent: curl/7.54.0
   < Forwarded: 
for=192.168.99.1;host=inventory-myproject.192.168.99.106.nip.io;proto=http;proto-version=
   < Date: Wed, 30 Oct 2019 23:42:25 GMT
   < X-Forwarded-Proto: http
   < X-Forwarded-Port: 80
   < X-Forwarded-For: 192.168.99.1
   < Content-Length: 0
   < X-Forwarded-Host: inventory-myproject.192.168.99.106.nip.io
   < Set-Cookie: 
e782efb2f1a658a2dcb1288019f96928=c01d8c86fb21c5bb7e6aaad972fb79a4; path=/; 
HttpOnly
   < 
   * Connection #0 to host inventory-myproject.192.168.99.106.nip.io left intact
   ```
   
   expected: ` {"inventoryId":"12345"}`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to