title: Add headers to every response
body: <p>How can I "automatically" add a header to every response with Silex?</p>
  
  <p>So far I have to do following with every response:</p>
  
  <pre class="lang-php prettyprint-override"><code>$app-&gt;post('/photos'), function () use ($app) {
      return $app-&gt;json(array('status' =&gt; 'success'), 200, array('Access-Control-Allow-Origin' =&gt; '*'));
  });
  </code></pre>
  
  <p>Instead, I would like to use a before filter to send <code>Access-Control-Allow-Origin: *</code> automatically with every request:</p>
  
  <pre class="lang-php prettyprint-override"><code>// Before
  $app-&gt;before(function () use ($app) {
      $response = new Response();
      $response-&gt;headers-&gt;set('Access-Control-Allow-Origin', '*');
  });
  
  // Route
  $app-&gt;post('/photos'), function () use ($app) {
      return $app-&gt;json(array('status' =&gt; 'success')); // &lt;-- Not working, because headers aren't added yet.
  });
  </code></pre>