Sha256: 9245baf7bb858e4781664cf0d7799798366a5313db36bb9f6cc454c1265183cf
Contents?: true
Size: 661 Bytes
Versions: 2
Compression:
Stored size: 661 Bytes
Contents
require 'multi_json' module Goliath module Rack module Formatters # A JSON formatter. Uses MultiJson so you can use the JSON # encoder that is right for your project. # # @example # use Goliath::Rack::Formatters::JSON class JSON include AsyncMiddleware def post_process(env, status, headers, body) if json_response?(headers) body = [MultiJson.dump(body)] end [status, headers, body] end def json_response?(headers) headers['Content-Type'] =~ %r{^application/((vnd\.api\+)?json|javascript)} end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
goliath-1.0.7 | lib/goliath/rack/formatters/json.rb |
goliath-1.0.6 | lib/goliath/rack/formatters/json.rb |