1
0
зеркало из https://github.com/glebtv/telegram-bot.git synced 2026-09-02 01:16:18 +03:00
Files
telegram-bot/lib/telegram/bot/middleware.rb
Max Melentiev 050df20533 Require action_dispatch fully
It uses autoload, so it's lazy-loaded. However there are missing some
internal requires so it will asks for more not-related `requires`
when requiring some files directly.
2018-05-30 11:43:05 +03:00

29 строки
632 B
Ruby

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)
[200, {}, ['']]
end
def inspect
"#<#{self.class.name}(#{controller.try!(:name)})>"
end
end
end
end