Sha256: ae08aff5dfdecddafa2fa8e154c78514da0d7b2c8ced4be137a90454b5a36ff6
Contents?: true
Size: 631 Bytes
Versions: 1
Compression:
Stored size: 631 Bytes
Contents
require_relative 'request' module TranslationEngine class KeysMiddleware URL_PATH = /\A\/translation_engine\/keys/ def initialize(app) @app = app end def call(env) if env['PATH_INFO'] =~ URL_PATH handle_redirect_request(env) else @app.call(env) end end private def handle_redirect_request(env) key_path = env['PATH_INFO'].gsub(URL_PATH, '') [ 302, { 'Location' => "#{TranslationEngine.api_host}/#{key_path}", 'Content-Type' => 'text/html' }, ['Moved Temporarily'] ] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
translation_engine-0.2.0 | app/middlewares/translation_engine/keys_middleware.rb |