A mini router for mruby and mri, uses trie for matching.
router = Mrouter.new
router.add_route '/resource(/:id(.:format))', {action: 'example'}
router.match '/resource' # => {:action=>"example"}
router.match '/resource/123.pdf' # => {:id=>"123", :format=>"pdf", :action=>"example"}
string
for exact string matching()
for optional matching:capture
for capture, stops at/
,.
Simply prefix the http method to the path, like:
router.add_route 'get /resource(/:id(.:format))', {method: 'GET', action: 'example'}
This gem only handle paths, not queries. You can use ngx_mruby's built-in Request or URI to process queries.
Route definitions are case sensitive. downcase
before match when necessary.
Include this gem at the test build section of build_config.rb
, then use mruby's make test
.