How to properly create a Plug module?
<p>I can create my own Plug Module this way <a href="http://www.phoenixframework.org/docs/understanding-plug#section-module-plugs" rel="nofollow">http://www.phoenixframework.org/docs/understanding-plug#section-module-plugs</a></p>

<p>Say, I wanted to check if there's a header in a request and its value and if they were corrent, continue further, if not,  terminate the current request and return a certain status and message, probably in json. </p>

<p>However, returning html or json or anything else from a Plug Module isn't allowed, it can only modify a connection structure passed to it on its way to a controller. </p>

<p>Then how would I do that? Should I add a certain key in it instead and then check for it in a controller? But it'd create a lot of repetition, wouldn't it?</p>

<pre><code>   # plug module
   def call(conn, default) do
     if condition1
       assign(conn, :my_key, %{status: :ok, msg: "okkkeey"})
     else
       assign(conn, :my_key, %{status: :error, msg: "we have problems")
   end

   # my_controller
   def action1(conn)
     # check for :my_key and its status
</code></pre>