Class: Rack::Oembed
- Inherits:
-
Object
- Object
- Rack::Oembed
- Defined in:
- lib/rack/oembed.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#oembed_path ⇒ Object
readonly
Returns the value of attribute oembed_path.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Oembed
constructor
A new instance of Oembed.
Constructor Details
#initialize(app, options = {}) ⇒ Oembed
Returns a new instance of Oembed.
5 6 7 8 9 |
# File 'lib/rack/oembed.rb', line 5 def initialize(app, ={}) @app = app @oembed_path = .fetch :path @oembed_path = "/#{}" unless .starts_with? "/" end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
3 4 5 |
# File 'lib/rack/oembed.rb', line 3 def app @app end |
#oembed_path ⇒ Object (readonly)
Returns the value of attribute oembed_path.
3 4 5 |
# File 'lib/rack/oembed.rb', line 3 def @oembed_path end |
Instance Method Details
#call(env) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/rack/oembed.rb', line 11 def call(env) if env["REQUEST_METHOD"] == "GET" && env["PATH_INFO"] == 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 |