Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
flatiron plugin to handle common responses
CoffeeScript JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
docs
test
.gitignore
.travis.yml
Cakefile
LICENSE
index.coffee
index.js
package.json
readme.md

readme.md

flatiron-handlers

build status

Flatiron Handlers is a flatiron http plugin provides the following methods to the flatiron http application:

Install

npm install flatiron-handlers

Usage

flatiron = require 'flatiron'
handlers = require 'flatiron-handlers'
app = flatiron.app

app.use flatiron.plugins.http
app.use handlers

app.router.get '/', ->
  app.plain res, 'foo'

API

app.text(res, text)

Parameter Type Required Description
res Object yes http response object
text string yes text to send in response

example

app.router.get '/', -> app.text @res, 'foobar'
app.router.get('/', function() { return app.text(@res, 'foobar') });

app.html(res, html)

Parameter Type Required Description
res Object yes Response Object
html string yes Html to return to response

example: see Source

app.redirect(res, location)

Parameter Type Required Description
res Object yes Response Object
location string yes location to redirect to

example: see Source

app.json(res, data, status)

Parameter Type Required Description
res Object yes Response Object
data Object yes JSON to return to response
status integer no status code to return with json response

example: see Source

roadmap

check issues

contribute

everyone is welcome to contribute. patches, bugfixes, new features

  1. create an issue on github so the community can comment on your idea
  2. fork flatiron-handlers in github
  3. create a new branch git checkout -b my_branch
  4. create tests for the changes you made
  5. make sure you pass both existing and newly inserted tests
  6. commit your changes
  7. push to your branch git push origin my_branch
  8. create an pull request

tests

npm install mocha -g
npm install
npm test

license

see LICENSE

Something went wrong with that request. Please try again.