0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-02 12:52:38 +00:00

add content negotiation middleware and tests

This commit is contained in:
Charlie Humphreys
2023-01-21 00:48:41 -06:00
parent 6bae21a578
commit 8b0203dd7c
3 changed files with 54 additions and 2 deletions

View File

@@ -0,0 +1,12 @@
module.exports = (req, res, next)=>{
const isImageRequest = req.get('Accept').split(',')
.filter((h)=>!h.includes('q='))
.every((h)=>/image\/.*/.test(h));
if(isImageRequest) {
return res.status(406).send({
message : 'Request for image at this URL is not supported'
});
}
next();
};