route.esl 406 B

12345678910111213141516
  1. (lambda (matcher handler)
  2. (if (=== (typeof matcher) "string") (block
  3. (var _matcher matcher)
  4. (= matcher (lambda (req) (return (=== req.url _matcher))))))
  5. ; TODO (if (instanceof matcher RegExp))
  6. (function route-handler (req res)
  7. (if (matcher req)
  8. (block (handler req res) (return true))
  9. (return false)))
  10. (= route-handler.tracked handler.tracked)
  11. (return route-handler))