class TheProtector::Middleware

Public Class Methods

new(app) click to toggle source
# File lib/the_protector/middleware.rb, line 3
def initialize(app)
  @app = app
end

Public Instance Methods

call(env) click to toggle source
# File lib/the_protector/middleware.rb, line 7
def call(env)
  if ENV["READ_ONLY"] == "true"
    if ["POST", "PUT", "PATCH", "DELETE"].include?(env["REQUEST_METHOD"])
      return [503, {'Content-Type' => 'text/plain'}, ['Service Unavailable']]
    end
  end

  @app.call(env)
end