Sha256: 01680e2cd2545a4bfda84cfe819adf4161c5a0725864635508adcb07538212b4
Contents?: true
Size: 576 Bytes
Versions: 20
Compression:
Stored size: 576 Bytes
Contents
module Rack class Oembed attr_reader :app, :oembed_path def initialize(app, options={}) @app = app @oembed_path = options.fetch :path @oembed_path = "/#{oembed_path}" unless oembed_path.starts_with? "/" end def call(env) if env["REQUEST_METHOD"] == "GET" && env["PATH_INFO"] == oembed_path url = Rack::Request.new(env).params.fetch("url") path = Addressable::URI.parse(url).path env["PATH_INFO"] = path env["HTTP_ACCEPT"] = "application/json+oembed" end app.call(env) end end end
Version data entries
20 entries across 20 versions & 1 rubygems