Incoming payload remapping & then forwarding to proxied service

In AWS API Gateway there is such concept of request templates. The idea is you can transform incoming payload to any other form using template language. Trying to find a way to make such transformation with caddy.

let’s imaging i have endpoint /hello-world this endpoint would consume any kind of payload and forward that to AWS SQS endpoint w/o need of nodejs or any server side 3rd party which would also listen on some port and then make calls.

If anyone familiar with aws gateway service request templates, can anything like this be done with caddy alone?

Caddy has templates (Caddyfile directive) — Caddy Documentation but this works on responses, not on requests. A plugin would need to buffer the whole request body, pipe it through a template or something, then pass it back through the rest of the HTTP handler chain.

I wrote a plugin that does something kinda like this for a sponsor a while ago, but it’s not general-purpose. It converts multipart forms to JSON. Still, it demonstrates that it can be done:

1 Like

seems like possible, thanks for replies, yet will have to stay with simple proxy for now, no time to build all plugin, but maybe this will inspire someone to make one :slight_smile:

This topic was automatically closed after 30 days. New replies are no longer allowed.