ruby on rails - Sinatra route regex constraints? -
i rebuild small rails (too overkill) app in sinatra. have route this:
match 'verify/:name/:bundle/:license' => 'verify#index', :constraints => { :bundle => /.*/ }
how can rebould in sinatra in terms of constraints attribute?
thanks!
you can either way: (taken sinatra's documentation)
get %r{/hello/([\w]+)} "hello, #{params[:captures].first}!" end
or inside block itself:
get '/hello/:name' raise sinatra::notfound unless params[:name].match /\w+/ "hello, #{params[:name]}!" end
Comments
Post a Comment