connect-ext-type

0.1.0 • Public • Published

Install

npm install connect-ext-type

Example usage

var express = require('express')
  , ext_type = require('connect-ext-type')
  , app = express();

app.use(ext_type({ '.txt': 'text/plain', '.json': 'application/json' }));

app.get('/foo', function(req, res, next) {
  res.format({
    text: function() { res.end('Plain text response'); },
    html: function() { res.json({ json: 'response' }); }
  });
});

Then, requesting "/foo.txt" would return "Plain text response", and requesting "/foo.json" would return "{ json: 'response' }".

License

MIT

Package Sidebar

Install

npm i connect-ext-type

Weekly Downloads

1

Version

0.1.0

License

MIT

Last publish

Collaborators

  • nadav