我需要同时提供http://localhost/users/list和http://localhost/users/list.html
server.get(/.*/, restify.serveStatic({
directory: './public',
}));
此代码仅在您指定.html扩展名时有效。
答案 0 :(得分:0)
我使用serve-static作为expressjs和http的中间件,并且有效。
var restify = require('restify');
var serveStatic = require('serve-static');
server = restify.createServer(options);
server.use(restify.acceptParser(server.acceptable));
server.use(restify.queryParser());
server.use(restify.bodyParser());
server.use(serveStatic('./public', { extensions: ['html'] }));
server.get(/.*/, restify.serveStatic({
directory: './public',
default: 'index.html',
}));
server.listen(80, function () {
console.log('Server is running...')
});