Pavel Tkackenko Pavel Tkackenko - 1 year ago 122
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?

Answer Source

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"]}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download