本文整理汇总了TypeScript中restify.plugins.conditionalHandler方法的典型用法代码示例。如果您正苦于以下问题:TypeScript plugins.conditionalHandler方法的具体用法?TypeScript plugins.conditionalHandler怎么用?TypeScript plugins.conditionalHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类restify.plugins
的用法示例。
在下文中一共展示了plugins.conditionalHandler方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: next
server.use(restify.plugins.bodyParser());
server.use(restify.plugins.throttle({
burst: 100,
rate: 50,
ip: true,
overrides: {
'192.168.1.1': {
rate: 0,
burst: 0
}
}
}));
server.use(restify.plugins.conditionalHandler([{
contentType: ['text/plain'],
handler: (req: restify.Request, res: restify.Response, next: restify.Next): void => {
res.send('OK');
next();
},
version: '0.0.0',
}]));
const logger = Logger.createLogger({ name: "test" });
server.on('after', restify.plugins.auditLogger({ event: 'after', log: logger }));
server.on('after', (req: restify.Request, res: restify.Response, route: restify.Route, err: any) => {
route.spec.method === 'GET';
route.spec.name === 'routeName';
route.spec.path === '/some/path';
route.spec.path === /\/some\/path\/.*/;
route.spec.versions === ['v1'];
restify.plugins.auditLogger({ event: 'after', log: logger })(req, res, route, err);