module Cas module Client class Rack def initialize(app) @app = app end def call(env) puts "CAS Client Called from Rack!" status, headers, rack_body = @app.call(env) puts "Middleware called. Status: #{status}, Headers: #{headers}" if rack_body.class == RackBody && rack_body.body.class == String response = rack_body.body response += "CAS Client Called!!!" headers["Content-Length"] = response.length.to_s return [status, headers, [response]] else return [status, headers, rack_body] end end end end end