diff options
Diffstat (limited to 'lib/http_ecs.rb')
-rw-r--r-- | lib/http_ecs.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/http_ecs.rb b/lib/http_ecs.rb new file mode 100644 index 0000000..2070dc0 --- /dev/null +++ b/lib/http_ecs.rb @@ -0,0 +1,25 @@ +class HttpEcs + + require 'rest_client' + include Singleton + + attr_reader :connection + + CONTENT_TYPE_URI_LIST = { 'Content-Type' => 'text/uri-list' } + CONTENT_TYPE_JSON = { 'Content-Type' => 'application/json' } + + def initialize + @connection= RestClient::Resource.new( + APP_CONFIG['ecs']['url'], + :ssl_ca_file => APP_CONFIG['ecs']['ssl_ca_file'], + :verify_ssl => APP_CONFIG['ecs']['verify_ssl'], + :headers => {"Content-Type" => :json, "Accept" => :json, "Authorization" => "Basic "+Base64.urlsafe_encode64(APP_CONFIG['ecs']['login']+":"+APP_CONFIG['ecs']['password'])} + ) + if APP_CONFIG['proxy'].blank? + RestClient.proxy = "" + else + RestClient.proxy = APP_CONFIG['proxy'] + end + end + +end |