Powered by Jekyll

Sinatra Routes in Orbit

Orbit 2.1.0’s dispatcher now accepts anything that answers to a match method for its routing patterns and returns a list of captures, instead of just strings that it interprets as standard Lua patterns. This means that you can now easily plug other kinds of pattern matchers, with the caveat that you only have the PATH_INFO available for matching.

As an example, I made a plugin for having Sinatra-like routes in your Orbit application, available here for Orbit 2.1.0 and through this rockspec if you have Git installed and want to track the bleeding edge of Orbit. It has as much of the Sinatra routes as I could understand from their test file: named parameters delimited by slashes or dots, splats delimited by slashes or dots, and optional named parameters. The test_routes.lua script is a good example of what is available.

This is “Hello World” example of how you can use this in an Orbit application:

blog comments powered by Disqus