Class: TinyCaptcha::Middleware

Inherits:
Object
  • Object
show all
Includes:
ImageHelpers
Defined in:
lib/tiny_captcha/middleware.rb

Constant Summary collapse

DEFAULT_SEND_FILE_OPTIONS =
{
  :type         => 'application/octet-stream'.freeze,
  :disposition  => 'attachment'.freeze,
}.freeze
CODE_KEY =
'code'

Constants included from ImageHelpers

ImageHelpers::DISTORTIONS

Instance Method Summary collapse

Methods included from ImageHelpers

distortion, image_params

Constructor Details

#initialize(app, options = {}) ⇒ Middleware

Returns a new instance of Middleware.



13
14
15
16
# File 'lib/tiny_captcha/middleware.rb', line 13

def initialize(app, options={})
  @app = app
  self
end

Instance Method Details

#call(env) ⇒ Object

:nodoc:



18
19
20
21
22
23
24
25
# File 'lib/tiny_captcha/middleware.rb', line 18

def call(env) # :nodoc:
  if env["REQUEST_METHOD"] == "GET" && env['PATH_INFO'].start_with?(::TinyCaptcha.image_show_path)
    # /tiny_captcha/images/show?code=abcdefg
    make_image(env)
  else
    @app.call(env)
  end
end