Skip to content

Instantly share code, notes, and snippets.

@NZKoz
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NZKoz/fdc4f6bd57c2709f7813 to your computer and use it in GitHub Desktop.
Save NZKoz/fdc4f6bd57c2709f7813 to your computer and use it in GitHub Desktop.
config.middleware.use "OldAcceptBehaviour", ["text/html", "application/xml", "text/javascript", "application/atom+xml"]
class OldAcceptBehaviour
def initialize(app, formats)
@app = app
@formats = formats
end
def call(env)
current_accept_header = env["HTTP_ACCEPT"]
if !@formats.include?(current_accept_header) && !env["HTTP_X_REQUESTED_WITH"]
env["HTTP_ACCEPT"] = "text/html"
end
@app.call(env)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment