Skip to content

About

Express middleware to conditionally use another express middleware.

Resources

Stars

16 stars

Watchers

1 watching

Forks

Latest commit

 

History

52 Commits

Folders and files

Repository files navigation

Express Conditional Middleware

Greenkeeper badge

travis build Coverage Status

This module provides a conditional middleware for express. Use as follows:

var conditional = require('express-conditional-middleware');

// Simple boolean method.
app.use(conditional(true, function (req, res, next) {
  // ...
});

// Function method.
app.use(conditional(
  function (req, res, next) {
    return req.get('accept') === 'application/json';
  },
  function (req, res, next) {
    // ...
  }
));

// Failure middleware.
app.use(conditional(
  function (req, res, next) {
    return req.get('accept') === 'application/json';
  },
  function (req, res, next) {
    // Executed if 'accept' === 'application/json'
  },
  function (req, res, next) {
    // Executed if 'accept' !== 'application/json'
  }
));

About

Express middleware to conditionally use another express middleware.

Resources

Stars

16 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages