【发布时间】:2019-08-01 02:32:27
【问题描述】:
我在 Node 中使用 Restify 来提供静态 img 文件,这是我的代码:
import * as Restify from "restify";
server.use(Restify.plugins.bodyParser());
server.use(Restify.plugins.queryParser());
server.get("/hostedImages/:file", HostedImagsHandler);
async function HostedImagsHandler(req: Restify.Request, res: Restify.Response, next) {
const path: string = req.params[1];
return next();
}
当我运行它时,我可以像这样提供文件:
http://localhost:5512/hostedImages/test.png
但是,我无法提供子目录中的任何文件:
http://localhost:5512/hostedImages/test/test.png
如何提供子文件夹?我正在运行 Restify 8.3.3,所以正则表达式路由不起作用。
【问题讨论】: