<commit_before>require 'alephant/broker/models/request_factory'
require 'alephant/broker/models/response_factory'

module Alephant
  module Broker
    class RequestHandler
      include Logger

      def initialize(env, config)
        @env = env
        @request = RequestFactory.new.process(env, request_type)
        @response_factory = ResponseFactory.new(env, config)
      end

      def process
        begin
          @response_factory.response_from(@request)
        rescue Exception => e
          logger.info("Broker.requestHandler.process: Exception raised (#{e.message})")
          @response_factory.response(500)
        end
      end

      private

      def request_type
        case @env.path.split('/')[1]
        when 'components'
          component_type
        when 'status'
          :status
        # how do we determine notfound or error status?
        end
      end

      def component_type
        case @env.method
        when 'POST'
          :component_batch
        when 'GET'
          :component
        end
      end
    end
  end
end<commit_msg>Ensure the NotFound class gets called<commit_after>require 'alephant/broker/models/request_factory'
require 'alephant/broker/models/response_factory'

module Alephant
  module Broker
    class RequestHandler
      include Logger

      def initialize(env, config)
        @env = env
        @request = RequestFactory.new.process(env, request_type)
        @response_factory = ResponseFactory.new(env, config)
      end

      def process
        begin
          @response_factory.response_from(@request)
        rescue Exception => e
          logger.info("Broker.requestHandler.process: Exception raised (#{e.message})")
          @response_factory.response(500)
        end
      end

      private

      def request_type
        case @env.path.split('/')[1]
        when 'components'
          component_type
        when 'status'
          :status
        else
          :notfound
        end
      end

      def component_type
        case @env.method
        when 'POST'
          :component_batch
        when 'GET'
          :component
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.07422775472568004, 'fraction_numerical': 0.0036883356385431073, 'mean_word_length': 1.9364005412719891, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1681730', 'n_tokens_mistral': 593, 'n_tokens_neox': 577, 'n_words': 146}