有没有什么办法来操纵Ruby中的URI来接受参数而不使用?
和&
?红宝石URI操纵
例如,我要做到以下几点:的
http://localhost:5000/service/get/ip/port
代替
http://localhost:5000/service?ip=192.168.1.1&port=1
要为指定的设备返回信息。这将利用完全基于REST的界面。
示例代码:
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
使用这个网址:http://localhost:5000/a/b 在上面,REQ对一个给定的URL输出将为:
GET /a/b HTTP/1.1
在 '请求',怎么可能一个去处理URI?
预先感谢您。
你使用Rails,Rack或其他来处理http请求吗? – 2010-08-18 21:00:35
是的,WEBrick处理所有传入的http请求。 – Yazdaan 2010-08-18 21:15:13