index.coffee | |
---|---|
flatiron handlersusage | |
Contants | PLAIN = 'text/plain'
HTML = 'text/html'
APP_JSON = 'application/json' |
Public methods | exports.attach = (options) -> |
app.plain(res, text)
example | @plain = (res, text) ->
res.writeHead 200, 'content-type': PLAIN
res.end text |
app.html(res, html)
example | @html = (res, html) ->
res.writeHead 200, 'content-type': HTML
res.end html |
app.redirect(res, location)
example | @redirect = (res, location) ->
res.writeHead 303, Location: location
res.end() |
app.json(res, data, status)
example | @json = (res, data, status=200) ->
res.writeHead status, 'content-type': APP_JSON
res.end JSON.stringify(data)
exports.init = (done) -> done()
|