0

I'm building a simple calculator for courier company. This calculator should receive some data via http request: weight, origin city and destination city. Then calculator should send back JSON or XML: price.

Sounds very simple, but I can't find any usable information how to handle with http request.

As I understand the request should be something like this:

localhost?weight=20&origin="Almaty"&destination="Moscow"

But I have no idea how to handle it with Rails. How to obtain these variables in HTTP?

4

1 に答える 1

0

ソケットを使用して、クライアントが http 要求を作成し、ソケットで受信し、計算して結果を返すようにする必要があります。

URL 属性パーサーのドキュメント: http://www.ruby-doc.org/stdlib-2.0/libdoc/cgi/rdoc/CGI.html#M000075

これは編集に役立つかもしれません:

require 'cgi'

CGI::parse('param1=value1&param2=value2&param3=value3')


returns you sth like that:

{"param1"=>["value1"], "param2"=>["value2"]}
于 2013-08-07T09:32:07.843 に答える