Pavel Tkackenko Pavel Tkackenko - 2 months ago 9x
HTTP Question

(Rails app Api) Send data via HTTP and receive JSON or XML

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:


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


You have to use sockets so the client get make a http request, you receive it on your socket, compute it and send him back the result.

Documentation for url attributes parser:

this might help edit:

require 'cgi'


returns you sth like that:

{"param1"=>["value1"], "param2"=>["value2"]}