Debugging Incoming Requests With Plug

A while back, we were working on a client project that required integrating AWS Lambdas with a Phoenix server. Each lambda would process an email and once the processing was complete, the lambda would send over a request with params to our Phoenix server. We found an issue where the lambda was sending a request, but the server was rejecting it because it couldn’t find a matching action.

We first started to debug the issue by pointing the lambda request to hookbin, which is a free service that can be used to receive and view HTTP requests. Hookbin successfully received the request by parsing incoming params correctly, so we expected our Phoenix server to be receiving it as well. But, the server responded that the action intended to get hit was not defined, indicating there was likely an issue with params causing the request to not match our controller action.

So we decided to capture and inspect the request on the Phoenix side to see what was actually coming through. And to do that we wrote a custom plug that sat in our middleware to capture the incoming request.

Sign up for our newsletter

Get notified of any new episodes as we release them.

© 2020 QuantLayer, LLC. All rights reserved.