express = require "express"
request = require "request"
app = express.createServer()
defaultResponse = (req,res,next) -> res.send req.originalUrl.substring(1)
app.get.propertyRoute = defaultResponse
app.get '/regularRoute', defaultResponse
app.all "/*", (req, res, next) ->
if r = (m = app[req.method.toLowerCase()])[req.originalUrl.substring(1)]
r.apply @, arguments
else
m req.originalUrl, arguments...
app.listen 8909
request {url: "http://localhost:8909/propertyRoute", method: 'GET'}, ->
console.log arguments[2]
request {url: "http://localhost:8909/regularRoute", method: 'GET'}, ->
console.log arguments[2]
resultados:
$ propertyRoute
$ regularRoute