oo-router

Created: 2012-03-25 17:52
Updated: 2014-04-24 12:29

README.md

OO-router

a HTTP router based on an OO interface

Concept

The HTTP verbs mean

OPTIONS -> return the valid HTTP verbs on the URI
HEAD -> GET without the body
POST -> invoke the function
PUT -> assign a property
PATCH -> partial update a property
DELETE -> delete a property
GET -> get the property

Routes constructed

 /routes/
   index.js 
   posts/
     index.js
     :post.js

Generates

/ (index.js)
/posts (posts/index.js)
/posts/:post/ (posts/:post.js)

Routes API

// index.js
module.exports = {
    deleteProperty: function (res, name) {
        // res.req === req
        // DELETE /name
    },
    get: function (res, name) {
        // GET /name
    },
    has: function (res, name) {
        // HEAD /name
    },
    set: function (res, name, body) {
        // PUT /name body
    },
    apply: function (res, ignoreReceiver, args) {
        // POST / args[0]
    },
    keys: function (res) {
        // return the urls supported /<one_of_keys>/
    }
}
Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more