本文整理汇总了TypeScript中express-serve-static-core.Router.httpMethod方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Router.httpMethod方法的具体用法?TypeScript Router.httpMethod怎么用?TypeScript Router.httpMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类express-serve-static-core.Router
的用法示例。
在下文中一共展示了Router.httpMethod方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: registerRouteHandlers
private registerRouteHandlers() {
for (let [route, handler] of this.routeHandlers.entries()) {
let httpMethod = route.requestConfig.method;
let path = route.requestConfig.path;
logger.debug(`Registering route. Path: '${path}', method: ${httpMethod}. Handler: ${ComponentUtil
.getComponentData(handler.constructor).componentName}.${route.methodHandler}()`);
this.router[httpMethod](path, this.wrap(async(request, response, next) => {
let result;
try {
result = await handler[route.methodHandler](request, response);
} catch (err) {
logger.debug("Error occurred in the route handler.");
next(new RouteHandlerError(`${handler.constructor.name}.${route.
methodHandler} failed on ${httpMethod.toUpperCase()} ${path}`, err));
return;
}
// TODO #3 saskodh: Check whether is more convenient to store in the request zone or pass on next
response.$$frameworkData = {
view: route.view,
model: result
};
next();
}));
}
}