I have a list of words in a list, and I want to handle get requests to any of them (and respond the same way).
@words = ["foo","bar"....etc]
One of the ways I thought I could do this is to loop through the list and have a get directive generated for each word when sinatra is launched.
@words.each do |word|
get word do
# what to do
end
end
that doesn't work, but something in that fashion, maybe.
Another way of doing it might be responding to get %r{/(.+)}
and then doing some processing inside there to see if it matches anything in the list and respond accordingly, but I'm interested nonetheless to see if there's a way I can do it as described above.