Skip to content

Instantly share code, notes, and snippets.

@polidog
Created March 23, 2013 14:48
Show Gist options
  • Save polidog/5227976 to your computer and use it in GitHub Desktop.
Save polidog/5227976 to your computer and use it in GitHub Desktop.
Dnode+cakephpのイベントハンドラ系処理
var dnode = require('dnode');
exports.requestAction = function(req, res){
dnode.connect(7070).on('remote',function(remote){
remote.callAction('/',null,{'domain':'localhost:3000'},function(html){
// console.log(html);
res.set('Content-Type', 'text/html');
res.send(html);
});
});
};
exports.model = function(req, res) {
dnode.connect(7070).on('remote',function(remote){
remote.callModel('Message','findById',[1],function(result){
var text = "title:"+result.Message.title;
text += "\n";
text += "body:" + result.Message.body;
res.set('Content-Type', 'text/plain charset=utf8');
res.send(text);
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment