Skip to content

An Express middleware to override the "content-type" header of the request

License

Notifications You must be signed in to change notification settings

rbartoli/express-content-type-override

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Express Content-Type Override Middleware

Npm package version Travis Npm dependencies Npm total dowloads License

An Express middleware to override the content-type header of the request.

Installation

$ npm install --save express-content-type-override

Usage

var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var registrationController = require('./controllers/registrationController');

var options = {
    contentType: 'application/x-www-form-urlencoded',
    charset: 'utf-8'
};

server.use('/registration', contentTypeOverride(options));
server.use(bodyParser.json());
server.use(bodyParser.urlencoded({
    extended: true
}));

app.post('/registration', registrationController);

app.listen(3000);

Options

options.contentType

Specify the content-type mime-type you'd like to use. Defaults to application/x-www-form-urlencoded.

options.charset

If you need to specify charset as part of content-type. No default, will not be part of content-type if not set.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

An Express middleware to override the "content-type" header of the request

Resources

License

Stars

Watchers

Forks

Packages

No packages published