Sha256: 10b2cbef2579b61f2f2d5856711c4b8b03790d430c3587d5ea296c95484dbfd1
Contents?: true
Size: 625 Bytes
Versions: 53
Compression:
Stored size: 625 Bytes
Contents
module Rack module PactBroker class AcceptsHtmlFilter def initialize app @app = app end def call env if accepts_html_and_not_json_or_csv env @app.call(env) else [404, {},[]] end end def accepts_html_and_not_json_or_csv env accept = env['HTTP_ACCEPT'] || '' accepts_html(accept) && !accepts_json_or_csv(accept) end def accepts_html(accept) accept.include?("html") end def accepts_json_or_csv accept accept.include?("json") || accept.include?("csv") end end end end
Version data entries
53 entries across 53 versions & 1 rubygems