title: How to send a custom header on every request with an angular resource?
body: <p>I like to send a custom header on every request with an angularjs resource. Before every request the header has to be created again. The following doesn't work. The header is calculated only once and because of this only one request works. A second request on the same resource fails. Its a lot of copy n paste of "headers: authhandler.createHeader()" also ...</p>
  
  <pre><code>myApp.service('Rest', ['$resource', 'authhandler',
          function($resource, 'authhandler',{
              return {
                  User: $resource( api_domain + "/api/users/:userid", {}, {
                      get: {method: 'GET', headers: authhandler.createHeader()},
                      remove: {method: 'DELETE', headers: authhandler.createHeader()},
                      edit: {method: 'PUT', headers: authhandler.createHeader()},
                      add: {method: 'POST', headers: authhandler.createHeader()},
                      patch: {method: 'PATCH', headers: authhandler.createHeader()}
                  }),
              };
          }]);
  </code></pre>
  
  <p>Has someone an idea how to solve this ?
  I had a working solution but I don't like it because of huge amount of copy and paste source code:</p>
  
  <pre><code>myApp.controller('MyController', function(RestResource, authhandler, $routeParams) {
      $http.defaults.headers.common = authhandler.createHeader();
      RestResource.get({userid: $routeParams.id}, function(result) {
          //...
      });
  });
  </code></pre>
  
  <p>I Would be very happy about hints how to solve this ! Thanks in advance!</p>