I’m working on a Phoenix app within an umbrella: it’s more or less one app per resource. That keeps things super-clean and tightly scoped, and it allows each app to operate independently because only the Phoenix app lists the other apps as dependencies.
What I’m wondering is how one can develop Phoenix Plugs as separate apps? Can anyone point me to existing packages available that do this? Mostly I can figure out how to set up the tests because Phoenix has a way of bootstrapping the conn Plug.Conn object. Any tips for this approach (or warnings against it)?
Thanks! I got started with the plug package, but my plug is returning JSON errors in some circumstances, e.g. when an error is encountered. In those cases, I am currently using Phoenix.Controller.json() to send a JSON error response. That makes this plug dependent on Phoenix… is there a better way to “throw” an error within a plug? Is there a better way to have Phoenix send the error response?
What plug package? Do you mean master_proxy package? I suggest you do something like acme_bank example. I am running something similar to that in production and working just fine. Your main application router which delegates the the sub apps will be called through their specific endpoints. Here is a link to the specific file you might want to look into for guidance.