Sha256: 70cce2677abccb813e36477374532ebc7e520c3ee5ffd6e44480b56903f65d3c
Contents?: true
Size: 756 Bytes
Versions: 1
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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dblink-0.4 | lib/dblink/web_service.rb |