Sha256: 5fa70396ee279a93fe0b92977225b958075479d622d0f7ebbed872324f4da596

Contents?: true

Size: 642 Bytes

Versions: 4

Compression:

Stored size: 642 Bytes

Contents

module YARD
  module Server
    module Commands
      # Serves requests from the root of the server
      class RootRequestCommand < Base
        def run
          favicon?

          self.body = "Could not find: #{request.path}"
          self.status = 404
        end

        private

        # Return an empty favicon.ico if it does not exist so that
        # browsers don't complain.
        def favicon?
          return unless request.path == '/favicon.ico'
          self.headers['Content-Type'] = 'image/png'
          self.status = 200
          self.body = ''
          raise FinishRequest
        end
      end
    end
  end
end

Version data entries

4 entries across 3 versions & 2 rubygems

Version Path
abaci-0.3.0 vendor/bundle/gems/yard-0.9.1/lib/yard/server/commands/root_request_command.rb
abaci-0.3.0 vendor/bundle/gems/yard-0.9.2/lib/yard/server/commands/root_request_command.rb
yard-0.9.2 lib/yard/server/commands/root_request_command.rb
yard-0.9.1 lib/yard/server/commands/root_request_command.rb