I am currently looking into Phoenix and i am wondering what happens to a plug connection after it finishes its plug pipeline.
conn
|> endpoint
|> router
|> controller
|> view
The documentation says, that the render/3
function will call the corresponding template function in the view and respond to the client with a status code of 200
. But what happens to the connection after this? Is the return used by any of the higher callers (for example the cowboy adapter), or does the pipeline simply finish with a open return that is unused?
Looking at the source code for Plug.Conn.send_resp/1
at the time of writing, you can see that the connection is first sent through the adapter, but it's then returned. This is because there can be other plugs that can get a connection with state: :sent
and do arbitrary stuff with it and the information it contains. The final return value (see here) is ultimately used by the adapter.