2021-03-01 15:06:11 +08:00

23 lines
308 B
JavaScript

'use strict'
/**
* Expose `conditional`.
*
* Conditional GET support middleware.
*
* @return {Function}
* @api public
*/
module.exports = function conditional () {
return async function (ctx, next) {
await next()
if (ctx.fresh) {
ctx.status = 304
ctx.body = null
}
}
}