Expresss.use(( 接受 2 个参数
app.use('/abcd', routeHandler);
Restify 仅支持一个
restify.use(routeHandler);
参考有关 https://github.com/restify/node-restify/issues/289 的解决方法
server.use(scopeMiddlewareTo('/prefix', myMiddleware));
我正在尝试使用此解决方法,但出现以下错误
{"code":"InternalError","message":"middleware.call is not a function"}
我正在使用打字稿,但即使是调试和中间件.call((时的JS代码也找不到。
基本上我在单独的文件中有路由,不希望在main.ts中使用restify.get((,restify.post((。单独的文件充当子应用程序。
您可以使用
此软件包 https://www.npmjs.com/package/restify-prefix-route。
var applyPrefix = require('restify-prefix-route');
server.pre(applyPrefix('/v1'));
使用此选项可在所有路由中添加前缀。