JSPM

content-types

0.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2440
  • Score
    100M100P100Q133619F

handle multiple content types

Package Exports

  • content-types

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (content-types) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

content-types build status

handle multiple content types

Example

var http = create("http")
    , contentTypes = require("routil-contentTypes")

http.createServer(function () {
    contentTypes(req, {
        "text/html": returnHtml
        , "application/javascript": returnJson
    })(req, res)
}).listen(8080)

function returnHtml(req, res) {
    res.end("<ul><li>foo</li><li>bar</li></ul>")
}

function returnJson(req, res) {
    res.end(JSON.stringify(["foo", "bar"]))
}

Installation

npm install content-types

Tests

npm test

Contributors

  • Raynos

MIT Licenced