node.js - Getting filetype in an Express route -
i have express route /doc/:id
serves html representation of document, , want serve epub representation when appended ".epub
". express doesn't separate on period, however, if use /doc/:id.epub
sets req.params.id
"id.epub
". there way have file extension recognised separate parameter or need use regex extract it?
i have looked @ res.format
, seems effective when accepted
header set, not if url typed browser, far can see.
this works:
app.get('/doc/:filename.:ext', function(req, res) { ... });
this requires part following /doc/
contains @ least 1 period, may or may not issue.
Comments
Post a Comment