(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&param2=value2&param3=value3')   returns sth that:  {"param1"=>["value1"], "param2"=>["value2"]} 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -