Sha256: 661ea9573fee816a15a10faab5428d584a1f691b80c552f7158ff9b990e8c6e9
Contents?: true
Size: 653 Bytes
Versions: 27
Compression:
Stored size: 653 Bytes
Contents
# encoding: utf-8 # rack seems to have problems with encoding, so this middleware enforce UTF-8 for all the strings in rack env module Rango module Middlewares class Encoding def initialize(app, encoding = ::Encoding.default_external) @app = app @encoding = encoding end def call(env) env.each do |key, value| env[try_force_encoding(key)] = try_force_encoding(value) end return @app.call(env) end protected def try_force_encoding(object) object.respond_to?(:force_encoding) ? object.dup.force_encoding(@encoding) : object end end end end
Version data entries
27 entries across 27 versions & 1 rubygems