Javascript 如何使用Iron路由器在Meteor中生成XML文件
我需要生成一个简单的XML文件来调用 目前,我正试图在特定路线上输出此信息:Javascript 如何使用Iron路由器在Meteor中生成XML文件,javascript,meteor,iron-router,Javascript,Meteor,Iron Router,我需要生成一个简单的XML文件来调用 目前,我正试图在特定路线上输出此信息: <?xml version="1.0" encoding="UTF-8"?> <Response> <Say voice="woman" language="en">Hello, world!</Say> </Response> 在答案的帮助下,我能够通过以下方式实现这一点: Router.route('/twilio/my_twiml.xml',
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say voice="woman" language="en">Hello, world!</Say>
</Response>
在答案的帮助下,我能够通过以下方式实现这一点:
Router.route('/twilio/my_twiml.xml', {
where: 'server',
action: function() {
var xmlData = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
xmlData += "<Response>";
xmlData += "<Say voice=\"woman\" language=\"en\">Hello!</Say>";
xmlData += "</Response>";
this.response.writeHead(200, {'Content-Type': 'application/xml'});
this.response.end(xmlData);
}
});
Router.route('/twilio/my_twiml.xml'{
其中:'服务器',
行动:功能(){
var xmlData=“”;
xmlData+=”;
xmlData+=“你好!”;
xmlData+=”;
writeHead(200,{'Content-Type':'application/xml'});
this.response.end(xmlData);
}
});
请注意,这是一个服务器端路由
Router.route('/twilio/my_twiml.xml', {
where: 'server',
action: function() {
var xmlData = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
xmlData += "<Response>";
xmlData += "<Say voice=\"woman\" language=\"en\">Hello!</Say>";
xmlData += "</Response>";
this.response.writeHead(200, {'Content-Type': 'application/xml'});
this.response.end(xmlData);
}
});