Sha256: f7552acc1ff27973dfc51ac7b5e321a506e4d88c5da4569a8615eac70975d2eb
Contents?: true
Size: 787 Bytes
Versions: 1
Compression:
Stored size: 787 Bytes
Contents
module Rack module JSONP class StatusWrapper def initialize(app) @app = app end def call(env) if env["jsonp.callback"] # Call original app status, headers, @body = @app.call(env) if headers["Content-Type"] == "application/json" @pre, @post = '{"body":', ', "status":' + status.to_s + '}' headers["Content-Length"] = (@pre.size + headers["Content-Length"].to_i + @post.size).to_s [status, headers, self] else [status, headers, @body] end else @app.call(env) end end def each(&block) block.call(@pre) @body.each(&block) block.call(@post) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rack-jsonp-tools-0.3.5 | lib/rack/jsonp/status_wrapper.rb |