(Rails app Api) Send data via HTTP and receive JSON or XML -
i'm building simple calculator courier company. calculator should receive data via http request: weight, origin city , destination city. calculator should send json or xml: price.
sounds simple, can't find usable information how handle http request.
as understand request should this:
localhost?weight=20&origin="almaty"&destination="moscow"
but have no idea how handle rails. how obtain these variables in http?
you have use sockets client make http request, receive on socket, compute , send him result.
documentation url attributes parser: http://www.ruby-doc.org/stdlib-2.0/libdoc/cgi/rdoc/cgi.html#m000075
this might edit:
require 'cgi' cgi::parse('param1=value1¶m2=value2¶m3=value3') returns sth that: {"param1"=>["value1"], "param2"=>["value2"]}
Comments
Post a Comment