access to Rainbows! config from within the application

Eric Wong normalperson at yhbt.net
Fri Sep 3 02:28:26 EDT 2010


russell muetzelfeldt <russm at slofith.org> wrote:
> Hi All,
> 
> Is there any way to read the server configuration from within the
> application that's being hosted?

Hi russell,

There's no stable/official internal API, and there probably won't be.
We try not to encourage propagating new, ad-hoc standards that other
Rack servers do not support.  Sometimes it's not easy to avoid (e.g.
async.callback + EventMachine stuff), but we try.

However, since the config file is Ruby, you can always use a global
variable in your config file.

> I'm about to add a Rainbows!-hosted file upload component to an
> existing application. At the moment I've got duplication between the
> app ("Note: maximum attachment size is 200MB") and rainbows.rb
> ("client_max_body_size 200*1024*1024") and am wondering if there's any
> way for the app to know what client_max_body_size the server is
> configured for so I can display a human-friendly version of that on
> the attachment page.

So something like this:

  Rainbows! do
    client_max_body_size($client_max_body_size = 200*1024*1024)
  end

If you have more variables you want to set, I know some folks
that use a global hash object or Struct, too.

> (please cc: replies as I'm not subscribed to the list)

-- 
Eric Wong


More information about the rainbows-talk mailing list