本文整理汇总了TypeScript中finalhandler.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: sendEmptyResponse
var server = http.createServer(function (request:http.ServerRequest, response:http.ServerResponse) {
// console.log((new Date()) + ' Received request for ' + request.url);
// response.writeHead(404);
// response.end();
var handled = false;
if (request.method === 'POST') {
handled = true;
var url = request.url;
if (url === '/__jalangi_startup__') {
console.log("starting up");
writeStream = fs.createWriteStream(OUTPUT_FILE_NAME);
sendEmptyResponse(response);
} else if (url === '/__jalangi_close__') {
writeStream.end("", function () {
console.log("done writing log")
});
sendEmptyResponse(response);
} else if (url === '/__jalangi_mem_trace__') {
var data = '';
request.on('data', function (chunk:string) {
data += chunk;
});
request.on('end', function () {
writeStream.write(data);
sendEmptyResponse(response);
})
} else {
handled = false;
}
}
if (!handled) {
var done = finalhandler(request, response);
serve(request, response, done);
}
});
示例2: finalhandler
appServer = http.createServer(function(req, res){
var done = finalhandler(req, res);
serve(req, res, done);
});
示例3: finalHandler
import {ServerRequest, ServerResponse} from "http";
import finalHandler from "finalhandler";
let req: ServerRequest;
let res: ServerResponse;
let options: {
onerror: (err: any, req: ServerRequest, res: ServerResponse) => void;
message: boolean|((err: any, status: number) => string);
stacktrace: boolean;
};
let result: (err: any) => void;
result = finalHandler(req, res);
result = finalHandler(req, res, options);
示例4: createServer
const server = createServer((req, res) => {
serve(req, res, finalhandler(req, res));
});
示例5: createServer
const server = createServer((request, response) => {
serve(request, response, finalHandler(request, response))
})