routil-contenttypes

0.0.1 • Public • Published

routil-contentTypes 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 routil-contentTypes

Tests

make test

Contributors

  • Raynos

MIT Licenced

/routil-contenttypes/

    Package Sidebar

    Install

    npm i routil-contenttypes

    Weekly Downloads

    0

    Version

    0.0.1

    License

    none

    Last publish

    Collaborators

    • raynos