Sha256: 8fed6aecafd9a0ff3e32a46532b0e4e15478bfc5cec13390780e07f7601e5532

Contents?: true

Size: 616 Bytes

Versions: 1

Compression:

Stored size: 616 Bytes

Contents

module Pakyow
  module Middleware
    class Static
      def initialize(app)
        @app = app
      end
      
      def call(env)
        if is_static?(env)
          response = Rack::Response.new
          
          catch(:halt) do
            Pakyow.app.send(File.open(File.join(Configuration::Base.app.public_dir, env['PATH_INFO'])))
          end
        else
          @app.call(env)
        end
      end
      
      private
      
      def is_static?(env)
        env['PATH_INFO'] =~ /\.(.*)$/ && File.exists?(File.join(Configuration::Base.app.public_dir, env['PATH_INFO']))
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pakyow-core-0.8rc1 pakyow-core/lib/core/middleware/static.rb