hojberg why do you go through Rails routing for combobot? Doesn't that defeat the purpose (performance) of going with a rack app? You can control the order of the middleware stack when loading them config.middleware.insert_after 'Rack::Cache', 'Rack::Combobot'
config.middleware.insert_after 'Rack::Cache', 'Rack::Combobot'
The performance gain for middleware versus Rails controller (without a view template) is probably negligible. Are you sure that this wouldn't be simpler as a Rails controller?
The RAILS_ROOT symbol is gone in Ruby 3.1. You'd use Rails.configuration.paths['public'].first instead.
Yeah, agreed. You should be doing this with middleware.
Im not sure how to do this with middleware for a specific route?
I don't think having it as a Rails controller is nice. I want to enable this functionality for Sinatra apps as well (which we would need in Swipely when we are doing the asset server)
Look at rubygems/rubygems.org, in particular how Hostess works.
I think that @cmeiklejohn was referring to: https://github.com/rubygems/rubygems.org/blob/master/app/middleware/hostess.rb
You can also do it without Sinatra with something like this:
@app = app
if Rack::Request.new(env).path == '/combobot'
Nice Josh - will get that going, thanks!