Skip to content

Instantly share code, notes, and snippets.

@elvuel
Created May 24, 2011 01:53
Show Gist options
  • Save elvuel/988020 to your computer and use it in GitHub Desktop.
Save elvuel/988020 to your computer and use it in GitHub Desktop.
page gen middle ware
# config.middleware.insert_after "ActionController::ParamsParser", "Rack::PageGen", :base_dir => '/tmp', :regular => :settings
# encoding: utf-8
module Rack
class PageGen
attr_reader :options
def initialize(app, options = {})
@app = app
@options = options
end
def call(env)
request = Rack::Request.new(env)
status, headers, response = @app.call(env)
# request.host, request.request_method, request.path
# 生成文件
if (headers["Content-Type"] =~ /text\/html|application\/xhtml\+xml/) and (status == 200) and request.get?
#pending
end
[status, headers, response]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment