index.js 308 B

12345678910111213141516171819202122
  1. 'use strict'
  2. /**
  3. * Expose `conditional`.
  4. *
  5. * Conditional GET support middleware.
  6. *
  7. * @return {Function}
  8. * @api public
  9. */
  10. module.exports = function conditional () {
  11. return async function (ctx, next) {
  12. await next()
  13. if (ctx.fresh) {
  14. ctx.status = 304
  15. ctx.body = null
  16. }
  17. }
  18. }