title: Universal Policy in Sails JS
body: <p>I have a policy to pass through all methods in my controllers. When call any method the policy fires up for the first time and it works great, but when call the same method for the second time there is no answer, it remains on hold for several minutes to respond.</p>
  
  <p>The code of my policy is:</p>
  
  <pre><code>module.exports = function (req,res,next){
              //Servicio Elogger
              var wsEloggerUrl = "prueba.com";
              //Código de la aplicación en Elogger
              var application = 'EVD';
              //Código del modulo
              var modulo = req.options.controller;
              //Código del controlador
              var controller = req.options.action;            
              //Valores a ser enviados en la cabecera obtenidos en las peticiones http
              var token = '86c6e394-4b20-4aef-b8a6-50aeea75ddc9'; //req.get('x-auth-token');
              var uid = 'uid'; //req.get('x-auth-uid'); 
              var code = application+'-'+modulo+'-'+controller;//'ELG-MOD-INDEX';
              var headers={ 'x-auth-token': token, 'x-auth-uid': uid, 'x-auth-code': code };
              //Variables a ultilizar en la llamada al webservices eLogger
              var http = require('http'), options = {
                    host : wsEloggerUrl,
                    port : 80,
                    path: '/api/Check',
                    method : 'GET',
                    headers: headers
              };
              //Llamada webServices eLogger
              http.request(options,function(response){
                    console.log(req.url+'---'+controller+'---'+response.statusCode);
                    //Si el estatus de la respuesta es diferente de 200
                    if (response.statusCode!=200) {
                          return res.json({
                                'operation': false,
                                'validation': null,
                                'services': null,
                                'error': response.statusCode,
                                'data': "Error en validación del token. HTTP Code: "+response.statusCode
                          });
                    }
  
                    next();
              }).end();
        }
  </code></pre>