swisspost / gateleen

Gateleen is a RESTful middleware toolkit for building API gateways
Other
77 stars 35 forks source link

Forward original payload to delegated destination #451

Closed mcweba closed 3 weeks ago

mcweba commented 2 years ago

With the delegate feature, one is able to peform two things with delegates:

With the current implementation, it is not possible to reuse the orignal payload and send it to a new destination. This feature can be best explained by the Tee command in Linux.

To achieve this, a new property called copy could be introduced. Finally there can be only one of the three properties be present in a delegate:

The need for this feature came up, when we wanted to delegate non-json payloads.

Kusig commented 2 years ago

So it is basically a NOP Transformation? The only open question I have is if we should allow really any body content here and if this might introduce any kind of security issue if there is no transformation in between as it will become a black-box mover?

mcweba commented 2 years ago

Yes I we want to handle this case as a transformation it would be a NOP. Regarding security, we have the same situation for a regular request forwarding (Forwarder) because anything can be forwarded. The only difference to the delegate is, that a copy of the request is forwarded somewhere else.

lbovet commented 2 years ago

If we don't do anything on the original payload, in what it differs from a routing rule or a hook?

mcweba commented 2 years ago

@lbovet good point. It differs from a regular routing rule because it duplicates the request. With a routing rule only, you can forward (or route) only to a single destination. I also thought about using hooks instead of extending the delegates. In the current implementation of a hook, it's not possible to use a destination including wildcards like the $1. You can just define a "static" destination without any url parameters and url segments from the original request. Instead of extending the delegates, we could also extend the hooks to be more flexible.

mcweba commented 2 months ago

See #606. It probably makes more sense to extend the hook feature to accept wildcards.