Skip to content
This repository has been archived by the owner on May 29, 2022. It is now read-only.

allow for https connections #3

Merged
merged 1 commit into from
Feb 18, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/pdns_api/http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ class HTTP
# It may include:
# - +:port+: Port the server listens on. Defaults to +8081+.
# - +:version+: Version of the API to use. Defaults to +1+.
# - +:scheme+: Scheme - HTTP or HTTPS. Defaults to +http+.
# The version of the API depends on the version of PowerDNS.
#
def initialize(args)
@host = args[:host]
@headers = { 'X-API-Key' => args[:key] }
@port = args.key?(:port) ? args[:port] : 8081
@version = args.key?(:version) ? args[:version] : api_version
@scheme = args.key?(:scheme) ? args[:scheme] : 'http'
end

##
Expand Down Expand Up @@ -108,7 +110,7 @@ def http(net, body = nil)

# Start an HTTP connection
begin
response = Net::HTTP.start(@host, @port) do |http|
response = Net::HTTP.start(@host, @port, use_ssl: @scheme == 'https') do |http|
# Do the request
http.request(net, body.to_json)
end
Expand Down