A livello di applicazione, è possibile aggiungere questo nel file application_controller.rb
before_filter :reject_methods
def reject_methods
if ['TRACE','PATCH'].include?(request.method)
#raise ActionController::RoutingError.new('Not Found')
raise ActionController::MethodNotAllowed.new('Method not allowed') #405
# or whatever you want to do (redirect, error message, ...)
end
end
Oppure si potrebbe provare con https://github.com/jtrupiano/rack-rewrite (controllare la riscrittura arbitrario) con qualcosa di simile (non testato):
rewrite %r{(.*)}, lambda { |match, rack_env|
rack_env["REQUEST_METHOD"] == "TRACE" ? "405.html" : match[1]
}
Oppure si potrebbe usare per possedere middleware mettendo questo in un file ./lib:
module Rack
class RejectMethods
def initialize(app)
@app = app
end
def call(env)
status, headers, body = @app.call(env)
if env["REQUEST_METHOD"] == "TRACE" || env["REQUEST_METHOD"] == "PATCH"
body.close if body.respond_to? :close
[status, headers, []]
else
[status, headers, body]
end
end
end
end
e chiamarlo in application.rb
config.autoload_paths += %W(#{config.root}/lib)
config.middleware.use "RejectMethods"
** Aggiornamento: ** Heroku ha ottenuto di nuovo me dicendo che non è possibile in là fine. Quindi ora è una domanda sul rifiuto del livello di applicazione. – Forrest
Va bene con Intuit o hai server di trasloco? –