<commit_before>
require 'webrick'
require 'wab'

module WAB
  module Impl

    # Handler for requests that fall under the path assigned to the
    # Controller. This is used only with the ::WAB::Impl::Shell.
    class Handler < WEBrick::HTTPServlet::AbstractServlet

      def initialize(server, shell)
        super(server)
        @shell = shell
      end

      def do_GET(req, res)
        ctrl, path, query, _ = extract_req(req)
        log_response('controller.read', path, query) if @shell.logger.info?
        send_result(ctrl.read(path, query), res)
      rescue Exception => e
        send_error(e, res)
      end

      def do_PUT(req, res)
        ctrl, path, query, body = extract_req(req)
        log_response_with_body('controller.create', path, query, body) if @shell.logger.info?
        send_result(ctrl.create(path, query, body), res)
      rescue Exception => e
        send_error(e, res)
      end

      def do_POST(req, res)
        ctrl, path, query, body = extract_req(req)
        log_response_with_body('controller.update', path, query, body) if @shell.logger.info?
        send_result(ctrl.update(path, query, body), res)
      rescue Exception => e
        send_error(e, res)
      end

      def do_DELETE(req, res)
        ctrl, path, query, _ = extract_req(req)
        log_response('controller.delete', path, query) if @shell.logger.info?<commit_msg>remove unnecessary parallel assignment to `_`<commit_after>
require 'webrick'
require 'wab'

module WAB
  module Impl

    # Handler for requests that fall under the path assigned to the
    # Controller. This is used only with the ::WAB::Impl::Shell.
    class Handler < WEBrick::HTTPServlet::AbstractServlet

      def initialize(server, shell)
        super(server)
        @shell = shell
      end

      def do_GET(req, res)
        ctrl, path, query = extract_req(req)
        log_response('controller.read', path, query) if @shell.logger.info?
        send_result(ctrl.read(path, query), res)
      rescue Exception => e
        send_error(e, res)
      end

      def do_PUT(req, res)
        ctrl, path, query, body = extract_req(req)
        log_response_with_body('controller.create', path, query, body) if @shell.logger.info?
        send_result(ctrl.create(path, query, body), res)
      rescue Exception => e
        send_error(e, res)
      end

      def do_POST(req, res)
        ctrl, path, query, body = extract_req(req)
        log_response_with_body('controller.update', path, query, body) if @shell.logger.info?
        send_result(ctrl.update(path, query, body), res)
      rescue Exception => e
        send_error(e, res)
      end

      def do_DELETE(req, res)
        ctrl, path, query = extract_req(req)
        log_response('controller.delete', path, query) if @shell.logger.info?
{'fraction_non_alphanumeric': 0.10673352435530085, 'fraction_numerical': 0.0, 'mean_word_length': 2.7641509433962264, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '1323351', 'n_tokens_mistral': 858, 'n_tokens_neox': 849, 'n_words': 242}