Sha256: c8b5a07dc13c8cb2feefd7f3739ba38458868f3b69d3adcf593ddeb785d4ad11
Contents?: true
Size: 546 Bytes
Versions: 7
Compression:
Stored size: 546 Bytes
Contents
# frozen_string_literal: true require 'htmlbeautifier' module Ruby2html class HtmlBeautifierMiddleware def initialize(app) @app = app end def call(env) status, headers, body = @app.call(env) if headers['Content-Type']&.include?('text/html') new_body = [] body.each do |chunk| new_body << HtmlBeautifier.beautify(chunk) end headers['Content-Length'] = new_body.map(&:bytesize).sum.to_s body = new_body end [status, headers, body] end end end
Version data entries
7 entries across 7 versions & 1 rubygems