Created
February 9, 2009 05:22
-
-
Save gnufied/60670 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# crux of thin patch | |
def pre_process | |
# Add client info to the request env | |
@request.remote_address = remote_address | |
# Process the request calling the Rack adapter | |
@app.call(@request.env) do |result| | |
post_process(result) | |
end | |
rescue Object | |
handle_error | |
terminate_request | |
post_process(nil) # Signal to post_process that the request could not be processed | |
end | |
# adapter now | |
module MsfService | |
class Adapter | |
attr_accessor :backend_server | |
def initialize | |
@backend_server = nil | |
end | |
def call(env,&response_proc) | |
@backend_server = BackEndConnection.connect | |
path = env['PATH_INFO'] | |
begin | |
_, controller, action = env['PATH_INFO'].split('/') | |
action,format = resolve_action(action) | |
a = Object.const_get("#{(controller || 'home').capitalize}Controller").new(env,format,@backend_server,response_proc) | |
a.call(action || 'index') | |
rescue | |
MSF_LOGGER.info($!.to_s) | |
MSF_LOGGER.info($!.backtrace.join("\n")) | |
render_invalid_response(env,&response_proc) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment