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>/
}
}