Sha256: 3596d0a9cf4601e45fe54ef38e41bcad8607935698ddc3873c418aa8de5f3231
Contents?: true
Size: 673 Bytes
Versions: 2
Compression:
Stored size: 673 Bytes
Contents
# frozen_string_literal: true module Html2Pdf module Rails class Client def self.post(*args) self.new(Html2Pdf.config.endpoint).post(*args) end def initialize(endpoint) @uri = URI.parse(endpoint) end def post(html, pdf_options = {}) http = Net::HTTP.new(@uri.host, @uri.port).tap { |h| h.use_ssl = @uri.scheme == 'https' } request = Net::HTTP::Post.new(@uri.request_uri, headers) request.body = { html: html, pdfOptions: pdf_options }.to_json http.request(request) end private def headers { 'Content-Type' => 'application/json' } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
html2pdf-rails-0.1.1 | lib/html2pdf/rails/client.rb |
html2pdf-rails-0.1.0 | lib/html2pdf/rails/client.rb |