On client
headers = {
list: {},
get: function(header, callback) {
return header ? this.list[header] : this.list;
}
}
Meteor.call('getReqHeaders', function(error, result) {
if (error) {
console.log(error);
}
else {
headers.list = result;
}
});
On server:
headers = {
list: {},
get: function(header) {
return header ? this.list[header] : this.list;
}
};
var app = typeof WebApp != 'undefined' ? WebApp.connectHandlers : __meteor_bootstrap__.app;
app.use(function(req, res, next) {
reqHeaders = req.headers;
return next();
});
Meteor.methods({
'getReqHeader': function(header) {
return reqHeaders[header];
},
'getReqHeaders': function () {
return reqHeaders;
},
});