How do you run middleware functions post response in Phoenix framework?
问题 I'm developing a simple website in Elixir with Phoenix. I'd like to add some custom middleware that runs after a response has been generated. For example, in order to log the total number of bytes in each response I'd like to have a Plug like this defmodule HelloWeb.Plugs.ByteLogger do import Plug.Conn require Logger def init(default), do: default def call(conn, default) do log("bytes sent: #{String.length(conn.resp_body)}") end end Trying to use this plug in one of the Phoenix pipelines in