i’m trying to make this code snippet from the sinatra tutorial work so that I can set some routes based on regex matching. it doesn’t seem to be working and I’m copy pasting direct from the tutorial, any ideas on what i’m missing. make the assumption that my sinatra app is working and i have other correctly structured GET routes working so I’m unclear why a direct copy past like this doesn’t work.
get %r{/hello/([\w]+)} do
"Hello, #{params[:captures].first}!"
end
should correct map a route for http://0.0.0.0:4567/hello but is routing to a ‘sinatra doesn’t know this ditty’ error message.
Thks.
%r{/hello/([\w]+)}doesn’t match/helloat all. Your regex requires a slash and another string, but your path doesn’t include that.That route would match
/hello/therebut not/helloor even/hello/.And given that you are looking at the captures, you probably don’t even want this to work with
/helloat all since that capture would beniland who want to say hello tonil?