Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A Node.js module for finding IANA registered names for common data types.
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
.gitignore
LICENSE
README.md
data_media_type.js
example.js
package.json

README.md

data-media-type

A Node.js module for finding IANA registered names for common data types.

See also:

Install

$ npm install data-media-type

Usage

var http = require('http');
var DataMediaType = require('data-media-type');

http.createServer(function(req, res) {
  res.statusCode = 200;
  res.setHeader('Content-Type', DataMediaType.JSON);

  var body = {
    hello: 'world'
  };

  res.end(JSON.stringify(body));
}).listen(1337);

Supported Media Types

  • DataMediaType.FORM_URLENCODED => application/x-www-form-urlencoded
  • DataMediaType.JSON => application/json
  • DataMediaType.MULTIPART_FORM_DATA => multipart/form-data
  • DataMediaType.OCTET_STREAM => application/octet-stream
  • DataMediaType.TEXT_PLAIN => text/plain
  • DataMediaType.TEXT_XML => text/xml
  • DataMediaType.XML => application/xml

License

MIT

Something went wrong with that request. Please try again.