I agree. The current signature can lead to a lot of confusion fast. We
also do not need to enforce the init/request split from a lifecycle
perspective as CommonJS Modules get initialized only once.
One area the simplified signature does not address is the passing of
options to the middleware for the init cycle. While I am using this
feature I do not see it as essential. Most options are or can be made
global to the stack and can be passed as part of the REQ/ENV. If the
middleware must initialize based on options from REQ/ENV it ought to
find common denominators that can be used to cache an initialized
request handler.
Alternatively one may make a call to the middleware module prior to
linking it into the stack in order to set options global to the module.
So overall I am +1 for this change to most importantly simplify the
signature and allow for easier comprehension.
Christoph
Christoph
--
You received this message because you are subscribed to the Google Groups "CommonJS" group.
To post to this group, send email to comm...@googlegroups.com.
To unsubscribe from this group, send email to commonjs+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/commonjs?hl=en.
Kris Kowal
--
You received this message because you are subscribed to the Google Groups "CommonJS" group.
To post to this group, send email to comm...@googlegroups.com.
To unsubscribe from this group, send email to commonjs+u...@googlegroups.com.
I venture to say that configuration management is an aspect that ought
to be unrelated to the JSGI interface.
The JSGI interface should define only the minimal method signature and
the properties on the request and response objects.
Configuration management is very much dependent on the environment the
middleware app runs in and on the preferences of the developer writing
the middleware app (very little consistency in naming conventions). It
is also static across multiple requests. It comes into play only during
the construction of the JSGI stack which makes it a bootstrap issue.
Current JSGI stack construction with options is messy without helpers
and hard to follow when scanning code.
I think we would be better off if we initialized middleware apps in a
flat sequence one after the other and then assembled them into the stack
we need in a second step.
I have the need to configure many of my modules, not just middleware
apps. Maybe module-level config management should get its own spec. By
separating config management and making it more parseable it can be
dealt with during build time when optimizing for environments removing
it from the runtime completely.
> benefit of making it possible to use a piece of middleware at multiple
> branches of a route. I do not think that it is particularly elitist to
> push JavaScripters to learn how to use closures.
For some reason this particular closure seems harder to understand. I
had a good understanding of closures yet the JSGI interface took me more
time to remember and understand. Maybe that is an indicator that it
combines too much? We are not even talking about streaming or returning
promises.
Christoph
For some reason this particular closure seems harder to understand. I had a good understanding of closures yet the JSGI interface took me more time to remember and understand. Maybe that is an indicator that it combines too much? We are not even talking about streaming or returning promises.
benefit of making it possible to use a piece of middleware at multiple
branches of a route. I do not think that it is particularly elitist to
push JavaScripters to learn how to use closures.