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

Version Path
houston-core-0.9.2 lib/rack/oembed.rb
houston-core-0.9.1 lib/rack/oembed.rb
houston-core-0.9.0 lib/rack/oembed.rb
houston-core-0.9.0.rc1 lib/rack/oembed.rb
houston-core-0.8.4 lib/rack/oembed.rb
houston-core-0.8.3 lib/rack/oembed.rb
houston-core-0.8.2 lib/rack/oembed.rb
houston-core-0.8.1 lib/rack/oembed.rb
houston-core-0.8.0 lib/rack/oembed.rb
houston-core-0.8.0.pre2 lib/rack/oembed.rb
houston-core-0.8.0.pre lib/rack/oembed.rb
houston-core-0.7.0 lib/rack/oembed.rb
houston-core-0.7.0.beta4 lib/rack/oembed.rb
houston-core-0.7.0.beta3 lib/rack/oembed.rb
houston-core-0.7.0.beta2 lib/rack/oembed.rb
houston-core-0.7.0.beta lib/rack/oembed.rb
houston-core-0.6.3 lib/rack/oembed.rb
houston-core-0.6.2 lib/rack/oembed.rb
houston-core-0.6.1 lib/rack/oembed.rb
houston-core-0.6.0 lib/rack/oembed.rb