0.0
No commit activity in last 3 years
No release in over 3 years
Rack::GridServe is a Rack middleware for serving files stored in MongoDB GridFS. It is meant as a simple replacement for Rack::GridFS until it is ready for Mongo driver version 2.0 and above.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 5.8
~> 0.6

Runtime

~> 2.0
>= 1.0
 Project Readme

Rack Grid Serve

The purpose of Rack::GridServe is to provide an alternative to Rack::Gridfs which works with the Mongo ruby driver version 2.0 and above. This driver has a different API and while the Rack::Gridfs team is working on it, it is not yet ready.

While Rack::GridServe can be used the same way, it is by no mean as complete and well crafted as Rack::Gridfs. So I recommend that you switch back when their next version is ready.

Until then, the function is the same, you can mount the middleware in order to serve images which are hosted in the GridFS part of a Mongo database.

How it works

Here is how you mount it in your config.ru:

require 'rack/grid_serve'
use Rack::GridServe, {
  db: $db,
  prefix: 'gridfs', # Path prefix, default is "gridfs"
  cache_control: 'no-cache' # Default is "no-cache"
}

These are the only options so far.

Rack::GridServe sets the ETag and Last-Modified response headers and uses Rack::ConditionalGet to let the browser use cached version of the files when possible.

Testing

Run tests this way:

bundle exec ruby -I lib test.rb