Sha256: cbc42eb076ca99f2cb1b760ea5462b2906879e5018fe2ba3263bafd1794263dd
Contents?: true
Size: 756 Bytes
Versions: 3
Compression:
Stored size: 756 Bytes
Contents
module WebService extend self #SERVICE_URL = "http://localhost:3000/dblinks" SERVICE_URL = "http://dblink.r15.railsrumble.com/dblinks" def register_link(database_url, is_public: false, verbose: false) require 'uri' require 'net/http' uri = URI(SERVICE_URL) http = Net::HTTP.new(uri.host, uri.port) request = Net::HTTP::Post.new(uri.path) params = { database_url: database_url, is_public: is_public } if verbose puts "HTTP POST: #{SERVICE_URL} #{JSON.generate(params)}" end response = http.post(uri.path, URI.encode_www_form(params)) if verbose puts response.class puts response.body end response_json = JSON.parse(response.body) response_json end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
dblink-0.4.3 | lib/dblink/web_service.rb |
dblink-0.4.2 | lib/dblink/web_service.rb |
dblink-0.4.1 | lib/dblink/web_service.rb |