本文整理匯總了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))
})