Controller plugs perform functionality before the action executes. Does Phoenix allow for post-action controller plugs? If not, is it by design?
Phoenix is a light wrapper around Plug. So, the
conn that you have in Phoenix is a
Plug.Conn. In plug, you can use Plug.Conn.register_before_send/2 to register a function to be called before the response is sent. Effectively, that’s after your controller action. This is different than the Rack model, where before and after are part of the same call stack. This is by design, because it allows things like streaming which are very hard to do in the Rack model.
There’s also this blog post, which goes into more detail about the motivations of the API.