Sha256: 78b084228f83507b410d3c1a071d83a20ca0dc271ce742639c7096bdf99e04cb

Contents?: true

Size: 666 Bytes

Versions: 3

Compression:

Stored size: 666 Bytes

Contents

# frozen_string_literal: true

require 'active_support/concern'
require 'active_support/core_ext/hash/indifferent_access'
require 'active_support/json'
require 'action_dispatch'

module Telegram
  module Bot
    class Middleware
      attr_reader :bot, :controller

      def initialize(bot, controller)
        @bot = bot
        @controller = controller
      end

      def call(env)
        request = ActionDispatch::Request.new(env)
        update = request.request_parameters
        controller.dispatch(bot, update, request)
        [200, {}, ['']]
      end

      def inspect
        "#<#{self.class.name}(#{controller&.name})>"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
telegram-bot-0.16.5 lib/telegram/bot/middleware.rb
telegram-bot-0.16.4 lib/telegram/bot/middleware.rb
telegram-bot-0.16.3 lib/telegram/bot/middleware.rb