You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: serverless_rack.rb
    path of file: ./repos/serverless-rack/lib
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

# This module handles conversion between API Gateway/ALB and Rack requests/responses.
#
# Author: Logan Raarup <logan@logan.dk>

require 'rack'
require 'base64'
require 'stringio'

TEXT_MIME_TYPES = [
  'application/json',
  'application/javascript',
  'application/xml',
  'application/vnd.api+json',
  'image/svg+xml'
    
def format_grouped_headers(headers:)
  { 'multiValueHeaders' => headers.transform_values do |value|
    value.split("\n")
  end }
end

def format_response(event:, status:, headers:, body:, text_mime_types:)
  response = { 'statusCode' => status }

  if event.include? 'multiValueHeaders'
    response.merge!(format_grouped_headers(headers: headers))
  else
    response.merge!(format_split_headers(headers: headers))
  end

  response.merge!(
    format_status_description(event: event, status: status)
  )

  response.merge!(
    format_body(
      body: body,
      headers: headers,
      text_mime_types: text_mime_types
    )
  )

  response
end