From the documentation:
server.get(/\/docs\/public\/?.*/, restify.plugins.serveStatic({
directory: './public'
}));
But this will search files in the ./public/docs/public/
directory.
If you want to not append request path to it, use appendRequestPath: false
option.
I prefer to use __dirname key here:
server.get(/\/public\/?.*/, restify.plugins.serveStatic({
directory: __dirname
}));
The value of __dirname
is equal to script file directory path, which assumed to be also a folder, where is public
directory.
And now we map all /public/.*
urls to ./public/
directory.
Now also exists serveStaticFiles plugin:
server.get('/public/*', // don't forget the `/*`
restify.plugins.serveStaticFiles('./doc/v1')
); // GET /public/index.html -> ./doc/v1/index.html file