Koa static file serving middleware, a modify of koa-static
$ npm install koa-static-plus
TOTALLY compatible to koa-static
pathPrefix
(string), Static path prefix string.maxage
Browser cache max-age in milliseconds. defaults to 0hidden
Allow transfer of hidden files. defaults to falseindex
Default file name, defaults to 'index.html'defer
If true, serves afterreturn next()
, allowing any downstream middleware to respond first.gzip
Try to serve the gzipped version of a file automatically when gzip is supported by a client and if the requested file with .gz extension exists. defaults to true.br
Try to serve the brotli version of a file automatically when brotli is supported by a client and if the requested file with .br extension exists (note, that brotli is only accepted over https). defaults to true.- setHeaders Function to set custom headers on response.
extensions
Try to match extensions from passed array to search for file when no extension is sufficed in URL. First found is served. (defaults tofalse
)
import koaStaticPlus from 'koa-static-plus'
// ... app = koa()
app.use(koaStaticPlus(path.join(__dirname, '../public'), {
pathPrefix: '/static'
})
// $ GET /static/hello.txt
// will to send the file ../public/hello.txt
@Ling.(wssgcg1213)
MIT