Class: Stoor::ReadOnly

Inherits:
Object
  • Object
show all
Includes:
Rack::Utils
Defined in:
lib/stoor/read_only.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, path) ⇒ ReadOnly

Returns a new instance of ReadOnly.



5
6
7
# File 'lib/stoor/read_only.rb', line 5

def initialize(app, path)
  @app, @path = app, path
end

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/stoor/read_only.rb', line 9

def call(env)
  request = Rack::Request.new(env)

  if request.path_info =~ /\A\/(create|delete)/ || request.post? || request.put?
    return [302, { 'Location' => @path }, []]
  end

  @app.call(env)
end