handle multiple content types
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
test
.gitignore
.npmignore
.travis.yml
LICENCE
README.md
index.js
package.json

README.md

content-types build status

handle multiple content types

Example

var http = create("http")
    , contentTypes = require("content-types")

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