Sha256: 1aa31a6e1036be2e9cc728042cd09e7cc32fa10647f74621ec79698446272456

Contents?: true

Size: 593 Bytes

Versions: 1

Compression:

Stored size: 593 Bytes

Contents

require 'rubygems'
require 'rack'

module MyApp
  module Test
    class Server
      def call(env)
        @root = "#{File.expand_path(File.dirname(__FILE__))}/../docs/"
        path = Rack::Utils.unescape(env['PATH_INFO'])
        path += 'index.html' if path == '/'
        file = @root + "#{path}"

        params = Rack::Utils.parse_nested_query(env['QUERY_STRING'])

        if File.exists?(file)
          [ 200, {"Content-Type" => "text/html"}, File.read(file) ]
        else
          [ 404, {'Content-Type' => 'text/plain'}, 'file not found' ]
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby_tika_app-1.0.1 spec/support/test_server.rb