Hello,
Is there any way to manipulate a URI in Ruby to accept parameters without the use of ?
and &
?
For example, I wish to do the following:
http://localhost:5000/service/get/ip/port
instead of
http://localhost:5000/service?ip=192.168.1.1&port=1
To return information for a given device. This would utilizes a fully REST-based interface.
example code:
hello_proc = lambda do |req,res|
res['Content-Type'] = "text/html"
res.body = %{
<html><body>
Hello. You are calling from a #{req['User-Agent']}
<p>
I see parameters: #{req.query.keys.join(', ')}
</body></html>
}
end
Using this URL: http://localhost:5000/a/b In the above, req's output for a given URL would be:
GET /a/b HTTP/1.1
Within 'req', how may one go about handling the URI?
Thank you in advance.