私はFlatiron Unionベースのアプリケーションで作業しています。ルートが実行される前にログを開発しているシンプルなロガーなので、何が起こったのかを正確には報告していないようです。私はUnionの例からロガーサンプルコードを取り出しました。ここで剥ぎ取らコードサンプルです:Flatiron Unionの "after"関数は "before"関数の前に実行されますか?
var
union = require('union')
, server;
server = union.createServer({
before: [ function (req,res) {
console.log('before');
res.writeHead(404, {"Content-Type": "text/plain"});
res.end("Hello World");
} ],
after: [
function LoggerStream() {
var stream = new union.ResponseStream();
stream.once("pipe", function (req) {
console.log({res: this.res.statusCode, method: this.req.method});
});
return stream;
}
]
});
server.listen(8800);
console.log('union running on 8800');
は、ここに私のコンソールに表示される内容です:報告されたステータスがなぜhttpサーバは、実際に404
を返さ200であることを
$ DEBUG=* node ./union.js
union running on 8800
{ res: 200, method: 'GET' }
before
注意これは順不同ですか?
会話をご覧ください:https://groups.google.com/forum/?fromgroups#!topic/flatironjs/9EFr2YWx8xY – Zhami