Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Recache API client for prerender.io
require 'net/http'
require 'json'
require 'uri'
class Prerender
ENDPOINTS = "https://api.prerender.io".freeze
def initialize(url, prerender_token)
@url = url
@prerender_token = prerender_token
end
def recache
post_params = {
url: url,
prerenderToken: prerender_token
}
res = Net::HTTP.post(
URI("#{ENDPOINTS}/recache"),
post_params.to_json,
'Content-Type' => 'application/json'
)
if res.code == '200'
puts "Successfully recache URL #{url}"
else
puts res.body
end
end
private
attr_reader :url, :prerender_token
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.