Created
September 1, 2011 09:17
-
-
Save dasch/1185778 to your computer and use it in GitHub Desktop.
Re-thought Rack API
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
class Middleware | |
# Processes a request before it reaches the application. | |
# | |
# The middleware can change the flow of the request/response chain by: | |
# - Raising an exception, which will halt the process | |
# - Returning an instance of Response, which will go through the middleware layer | |
# | |
# Returning any other value will not do anything. | |
def process_request(request) | |
# ... | |
end | |
def process_response(request, response) | |
# ... | |
end | |
def process_exception(request, exception) | |
# ... | |
end | |
end |
Perhaps :-)
It would allow non-recursive middleware processing, e.g.
middlewares.each {|middleware| middleware.process_request(request) }
response = application.call(request)
middlewares.reverse.each {|middleware| middleware.process_response(request, response) }
This is overly simplified, but should alleviate some of the GC issues caused by Rack.
Perhaps :-)
It would allow non-recursive middleware processing, e.g.
middlewares.each {|middleware| middleware.process_request(request) }
response = application.call(request)
middlewares.reverse.each {|middleware| middleware.process_response(request, response) }
This is overly simplified, but should alleviate some of the GC issues caused by Rack.
##
Daniel Schierbeck
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)
…On tirsdag den 27. september 2011 at 12.00, mkristian wrote:
looks like java-servlets to me ;-)
##
Reply to this email directly or view it on GitHub:
https://gist.github.com/1185778
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
looks like java-servlets to me ;-)