Class: Rack::Legacy::Cgi
- Inherits:
-
Object
- Object
- Rack::Legacy::Cgi
- Defined in:
- lib/rack/legacy/cgi.rb
Direct Known Subclasses
Instance Attribute Summary (collapse)
-
- (Object) public_dir
readonly
Returns the value of attribute public_dir.
Instance Method Summary (collapse)
-
- (Object) call(env)
Middleware, so if it looks like we can run it then do so.
-
- (Cgi) initialize(app, public_dir = FileUtils.pwd)
constructor
Will setup a new instance of the Cgi middleware executing programs located in the given public_dir.
-
- (Boolean) valid?(path)
Check to ensure the path exists and it is a child of the public directory.
Constructor Details
- (Cgi) initialize(app, public_dir = FileUtils.pwd)
Will setup a new instance of the Cgi middleware executing programs located in the given public_dir
use Rack::Legacy::Cgi, 'cgi-bin'
14 15 16 17 |
# File 'lib/rack/legacy/cgi.rb', line 14 def initialize(app, public_dir=FileUtils.pwd) @app = app @public_dir = public_dir end |
Instance Attribute Details
- (Object) public_dir (readonly)
Returns the value of attribute public_dir
8 9 10 |
# File 'lib/rack/legacy/cgi.rb', line 8 def public_dir @public_dir end |
Instance Method Details
- (Object) call(env)
Middleware, so if it looks like we can run it then do so. Otherwise send it on for someone else to handle.
21 22 23 24 25 26 27 |
# File 'lib/rack/legacy/cgi.rb', line 21 def call(env) if valid? env['PATH_INFO'] run env, full_path(env['PATH_INFO']) else @app.call env end end |
- (Boolean) valid?(path)
Check to ensure the path exists and it is a child of the public directory.
31 32 33 34 35 |
# File 'lib/rack/legacy/cgi.rb', line 31 def valid?(path) fp = full_path path fp.start_with?(::File. public_dir) && ::File.file?(fp) && ::File.executable?(fp) end |