Sha256: deacae51e0aa98253307afd557158e8be7d67edba35e4ccfc4958fea1a393396
Contents?: true
Size: 756 Bytes
Versions: 1
Compression:
Stored size: 756 Bytes
Contents
require_relative 'request' module TranslationEngine class ScreenshotsMiddleware include Request URL_PATH = /\A\/translation_engine\/screenshots/ def initialize(app) @app = app end def call(env) if TranslationEngine.use_screenshots && env['PATH_INFO'] =~ URL_PATH handle_translation_request(env) else @app.call(env) end end private def handle_translation_request(env) data = JSON.parse(env["rack.input"].read) TranslationEngine::Connection.new .send_images(data.merge(locale: I18n.locale), remote_ip(env)) [ 200, { 'Content-Type' => 'application/json' }, [{ message: 'translations saved' }.to_json] ] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
translation_engine-0.2.0 | app/middlewares/translation_engine/screenshots_middleware.rb |