Comments (5)
When you launch eel out of the box it will start listening for events on port 8080 using a default handler stored here https://github.com/Comcast/eel/blob/master/config-handlers/tenant1/default.json
The easiest thing to do would be to modify this default handler so it performs your transformation. You also need to adjust the endpoint you want to forward the transformed event to. Something like this should do:
{
"Version": "1.0",
"Name": "Default",
"Info": "Default handler for everything. Doesn't apply any transformation and forwards everything unchanged to Endpoint/Path.",
"Active": true,
"Match": null,
"IsMatchByExample": false,
"TerminateOnMatch": true,
"Transformation": {
"{{/}}": "{{/items}}"
},
"IsTransformationByExample": false,
"Path": "",
"Verb": "POST",
"Endpoint": "http://myproxytarget",
"Protocol": "http",
"HttpHeaders": {
"X-B3-TraceId": "{{traceid()}}",
"X-Tenant-Id": "{{tenant()}}"
}
}
Hope this helps!
from eel.
Thanks Boris. Unfortunately this doesn’t help my required.
I need to:
Send GET request to eel and forward to target server as is.
Transform the JSON response from target server and pass onto the originating client.
Is this something eel can do?
from eel.
Yes, you can do this with eel as well. First of all you need to hit a different endpoint of eel: use /v1/sync/events
to receive a synchronous response from eel rather than the default /v1/events
which is used for event forwarding.
Next you might find the various built-in functions eel has useful. They are documented here:
https://github.com/Comcast/eel/blob/master/doc/functions.md
I put together an example for you based on your requirements using the functions curl(), eval() and prop(). I'm also using a custom properties section in the handler to manage the request against your service.
{
"Version": "1.0",
"Name": "Default",
"Info": "Hit a remote service with the original payload and synchronously return a transformed response to original requestor.",
"Active": true,
"Match": null,
"IsMatchByExample": false,
"TerminateOnMatch": true,
"Transformation": {
"{{/}}": "{{eval('/items','{{prop('resp')}}')}}"
},
"CustomProperties" : {
"resp" : "{{curl('GET', 'http://foo.com/bar', '{{/}}')}}"
},
"IsTransformationByExample": false,
"Protocol": "null",
"HttpHeaders": {
"X-B3-TraceId": "{{traceid()}}",
"X-Tenant-Id": "{{tenant()}}"
}
}
Give this handler a try. You will probably have to fine tune it a little.
from eel.
Thanks for the pointers Boris.
I have configured as suggested above and it is working perfectly with POST to http://localhost:8080/v1/sync/events
However, my original requester can only issue GET (limitation in the application). But when I try using GET to get the response I have the following:
Browser output is:
{"error":"http post required","tx.traceId":"e47ead52-b2a9-40c1-8b11-2a4c10a2507e"}
Console output is:
{"action":"rejected","app.id":"eel","cause":"http_post_required","env.name":"default","error":"post required","error_type":"rejected","instance.id":"xxxxxxx","log.id":"e47ead52-b2a9-40c1-8b11-2a4c10a2507e","log.level":"error","log.timestamp":"2019-07-23T08:41:08.577866555Z","method":"GET","status":"400","tx.traceId":"e47ead52-b2a9-40c1-8b11-2a4c10a2507e"}
It is possible for eel to accept GET?
from eel.
Interesting. Before I was still assuming that your original request was posting a payload you wish to forward to your target service. If this is not the case and you simply want to kick this off with a payload-free GET request you are out of luck. EEL is designed to work around an incoming http POST and a (possibly empty) payload that is sent along with it.
from eel.
Related Issues (20)
- Engraved in code transformation. HOT 3
- Unmatched quotes in jtp/inproc.go:127 HOT 1
- How-to questions on submitting pull-requests HOT 1
- Docker build error HOT 1
- Insert root element into an array
- fatal error: concurrent map iteration and map write
- -config flag listed as optional, is actually required HOT 2
- Add travis ci support HOT 1
- Event handler should return 202 instead of 200 HOT 1
- Need help on both request & responce transformation HOT 1
- Headers problem HOT 3
- eval - cannot get a single value HOT 6
- How to use multiple "curl"s correctly ? HOT 3
- Is there such thing as "try..catch" ? HOT 1
- One handler or many handlers ?
- Multiple elements arrays howto ? HOT 1
- SSL support HOT 1
- Alphabet sorting enable/disable ? HOT 1
- How to extract
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eel.