Class: Rack::GridFS
- Inherits:
-
Object
- Object
- Rack::GridFS
- Defined in:
- lib/rack/gridfs.rb,
lib/rack/gridfs/version.rb,
lib/rack/gridfs/endpoint.rb,
lib/rack/gridfs/endpoint/base.rb,
lib/rack/gridfs/endpoint/caching.rb,
lib/rack/gridfs/endpoint/connection.rb
Overview
Rack middleware that will serve GridFS files from a specified path prefix. By default the prefix is stripped from the path before file lookup in GridFS occurs.
For example:
"/gridfs/filename.png" -> "filename.png"
If you are using Rails you can mount the endpoint directly.
For example (in config/routes.rb):
mount Rack::GridFS::Endpoint, :at => "gridfs"
Defined Under Namespace
Classes: Endpoint
Constant Summary collapse
- VERSION =
"0.4.3"
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ GridFS
constructor
A new instance of GridFS.
Constructor Details
#initialize(app, options = {}) ⇒ GridFS
Returns a new instance of GridFS.
25 26 27 28 |
# File 'lib/rack/gridfs.rb', line 25 def initialize(app, ={}) @app = app @options = () end |
Instance Method Details
#call(env) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/rack/gridfs.rb', line 30 def call(env) if env['PATH_INFO'] =~ %r{^/#{@options[:prefix]}/*} endpoint.call(env) else @app.call(env) end end |