runways

0.1.1 • Public • Published

Runways - a route dispatcher for connect

Runways is middleware that adds robust explicit routing to connect

Usage

connect = require('connect');
router = require('runways');

> routes can be added at any time, but we'll give an example here

> router.add(<name>,<route>,<callback>,<http methods (default: get)>)

> default static route
router.add("default","/",function(req,route) { return "hello, runways" });

> dynamic route with a parameter
router.add("hello","/hello/{name}", function(req,route) { return "hello, " + route.params.get(name) });

> dynamic route with a parameter and a default
router.add("hi", "/hi/{name:there}", function(req,route) { return "hi, " + route.params.get(name) + "!" });

// define our server with our middleware
server = connect.createServer(router.routes());

// start the server
server.listen(3000);

License

MIT License. See LICENSE.md

Readme

Keywords

none

Package Sidebar

Install

npm i runways

Weekly Downloads

1

Version

0.1.1

License

none

Last publish

Collaborators

  • sjsadowski