[github地点:https://github.com/ABCDdouyae…]
cache-content-type(koa2源码依靠)
http相应头部工具包, 基于mime-types包,对效果进行了缓存
const getType = require('cache-content-type');
const contentType = getType('html');
console.log(contentType);//text/html; charset=utf-8
mime-types
mime.lookup(path)
mime.lookup('json') // 'application/json'
mime.lookup('.md') // 'text/markdown'
mime.lookup('file.html') // 'text/html'
mime.lookup('folder/file.js') // 'application/javascript'
mime.lookup('folder/.htaccess') // false
mime.lookup('cats') // false
mime.contentType(type) 猎取完成的头部
mime.contentType('markdown') // 'text/x-markdown; charset=utf-8'
mime.contentType('file.json') // 'application/json; charset=utf-8'
// from a full path
mime.contentType(path.extname('/path/to/file.json')) // 'application/json; charset=utf-8'
mime.extension(type) 猎取范例的默许扩展名
mime.extension('application/octet-stream') // 'bin'
mime.charset(type) 猎取默许字符编码
mime.charset('text/markdown') // 'UTF-8'