Class: Gister::Middleware
- Inherits:
-
Object
- Object
- Gister::Middleware
- Defined in:
- lib/gister/middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, fetcher = Fetcher.new) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app, fetcher = Fetcher.new) ⇒ Middleware
Returns a new instance of Middleware.
7 8 9 10 |
# File 'lib/gister/middleware.rb', line 7 def initialize(app, fetcher=Fetcher.new) @app = app @fetcher = fetcher end |
Instance Method Details
#call(env) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/gister/middleware.rb', line 12 def call(env) request = Rack::Request.new env if request.path =~ /^\/gist\/([A-Za-z\-0-9]+\/)?[0-9]+.json/ respond_to_failures do [200, {'Content-Type' => 'application/javascript'}, [get_body_content(request)]] end else @app.call(env) end end |