Sha256: 921694fc794f4982464c71f7425464e24f28ddc4e24f56909397daa850a1a037

Contents?: true

Size: 618 Bytes

Versions: 1

Compression:

Stored size: 618 Bytes

Contents

# frozen_string_literal: true

module Ki
  module Middleware
    class InitMiddleware
      include BaseMiddleware

      def call(env)
        req = BaseRequest.new env
        if req.root?
          if public_file_exists? 'index.html'
            env['PATH_INFO'] = '/index.html'
            Rack::File.new(Ki::PUBLIC_PATH).call env
          else
            resp = Rack::Response.new
            resp.redirect('/index')
            resp.finish
          end
        else
          env['CONTENT_TYPE'] = 'application/json' if format_of(req) == 'json'
          @app.call env
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ki-0.4.12 lib/ki/middleware/init_middleware.rb