Permalink
Browse files

updated readme

  • Loading branch information...
1 parent 9dbe421 commit 5a1078894cc9d32039476f0c7e248659abb01753 @hojberg committed Jan 5, 2012
Showing with 1 addition and 1 deletion.
  1. +1 −1 README.md
View
@@ -11,5 +11,5 @@ gem install rack-combobot
In your routes.rb file add the following route
```ruby
- match 'combot', :to => Rack::Combobot.configure(:root => "/public")
+match '/combobot', :to => Rack::Combobot.configure(:root => RAILS_ROOT + "/public")
```

7 comments on commit 5a10788

@joshuanapoli
Collaborator

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'

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.

@cmeiklejohn
Collaborator

Yeah, agreed. You should be doing this with middleware.

@hojberg
Owner

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)

@cmeiklejohn
Collaborator

Look at rubygems/rubygems.org, in particular how Hostess works.

@joshuanapoli
Collaborator

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:

class Rack::Combobot
  def initialize(app)
    @app = app
  end

  def call(env)
    if Rack::Request.new(env).path == '/combobot'
      combine(env)
    else
      @app.call(env)
    end
end
@hojberg
Owner

Nice Josh - will get that going, thanks!

@hojberg
Owner

#12

Please sign in to comment.