| Class | Capcode::StaticFiles |
| In: |
lib/capcode.rb
|
| Parent: | Object |
# File lib/capcode.rb, line 356
356: def call(env)
357: static = File.expand_path( File.join(Capcode::Configuration.get(:root), Capcode::Configuration.get(:static) ) )
358: file = File.join(static, env['REQUEST_PATH'].split("/") )
359: file = File.join(file, "index.html" ) if File.directory?(file)
360: if File.exist?(file)
361: body = [::File.read(file)]
362: header = {
363: "Last-Modified" => ::File.mtime(file).httpdate,
364: "Content-Type" => ::Rack::Mime.mime_type(::File.extname(file), 'text/plain'),
365: "Content-Length" => body.first.size.to_s
366: }
367: return [200, header, body]
368: else
369: return @app.call(env)
370: end
371:
372: return @app.call(env)
373: end