Sha256: b9a37516ffb2a8c8e05f203c8d1bfa60f4fc237960aff9cc4a14170d3f472473
Contents?: true
Size: 728 Bytes
Versions: 6
Compression:
Stored size: 728 Bytes
Contents
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
6 entries across 6 versions & 1 rubygems