Skip to content

Commit

Permalink
Merge pull request #81 from mattrayner/mattrayner/add-post-ability
Browse files Browse the repository at this point in the history
Update base_request to properly handle posts
  • Loading branch information
mattrayner committed Nov 7, 2017
2 parents c072cfd + a2b4b2f commit 3f13f7e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
15 changes: 9 additions & 6 deletions lib/parliament/request/base_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,16 @@ def post(params: nil, body: nil)
http = Net::HTTP.new(endpoint_uri.host, endpoint_uri.port)
http.use_ssl = true if endpoint_uri.scheme == 'https'

net_response = http.start do |h|
api_request = Net::HTTP::Post.new(endpoint_uri.request_uri)
add_headers(api_request)
api_request.body = body unless body.nil?
request = Net::HTTP::Post.new(
endpoint_uri.request_uri,
'Content-Type' => 'application/json'
)

h.request api_request
end
add_headers(request)

request.body = body unless body.nil?

net_response = http.request(request)

handle_errors(net_response)

Expand Down
2 changes: 1 addition & 1 deletion lib/parliament/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Parliament
VERSION = '0.9.0'.freeze
VERSION = '0.10.0'.freeze
end

0 comments on commit 3f13f7e

Please sign in to comment.