terraform icon indicating copy to clipboard operation
terraform copied to clipboard

Proxy from within controller action

Open tfwright opened this issue 3 years ago • 0 comments

Hi, great library, it has made migrating my legacy rails app to Phoenix a breeze.

Recently I had an endpoint I needed to migrate that has drastically different behavior depending on request params. Not an ideal design, but since I'm dealing with some pretty complex legacy code, I really wanted to migrate only one implementation at a time. However, since Phoenix doesn't support matching routes based on query parameters (AFAIK), I couldn't rely on terraform's default behavior. What I ended up doing was using pattern matching and manually calling the plug, which seemed to work great, but I did run into an issue where since the raw body had already been read and discarded, they weren't getting sent along to the Rails app. So I just wrote another simple plug to cache the original body and check for that in my terraform plug.

So my question is, would it make sense to build in an official way to handle this within terraform? I would be happy to contribute the code I already wrote and/or open a PR.

tfwright avatar Jun 29 '21 11:06 tfwright