我正在尝试使用rubzy框架Ramaze来实现RESTful控制器。但是,当我发送PUT时,我似乎无法访问请求中的数据。示例代码:
require 'ramaze'
class PutController < Ramaze::Controller
map '/'
def index
"Argument of "+request[:id]
end
end
Ramaze.start
我通过curl与它进行交互:
% curl -d id=5 "http://localhost:7000/"
Argument of 5
% curl -v -X PUT -d id=5 "http://localhost:7000/" > /dev/null
...
HTTP/1.1 500 Internal Server Error
[With a backtrace revealing that the request object is nil]
我做错了吗?我怎么能在Ramaze中获得PUT请求的主体?
答案 0 :(得分:3)
试试这个:
require 'rubygems'
require 'ramaze'
class PutController < Ramaze::Controller
map '/'
def index
"Argument of "+request.POST['id']
end
end
Ramaze.start
它适用于PUT以及POST和GET。