Closed elazar closed 9 years ago
@elazar Have you done anything further with this?
@pmjones I personally have not, no. However, Spark recently merged an implementation of this concept if you'd like to have a look at that.
Just looked at it, thanks. I can see why this is appealing, especially in a middleware-style system. Even so, I don't think it's necessarily something for the Radar core. I reserve the right to change my mind later. ;-)
Relay implements a callback chain whereby requests and responses can be modified prior to being processed by Radar actions. I'm wondering if a similar concept wouldn't be useful in the context of Radar responders, the purpose being to support multiple modularized potential changes to the response based on information in the payload returned by the domain.
For example, I may want to have a
RedirectResponder
. which would allow my actions to store a URL in the payload associated with a key'redirect'
and could perform a HTTP redirect to that URL by setting the response status andLocation
header appropriately.This concept could be accomplished with the current implementation by creating a custom
CompositeResponder
that simply takes other responders and invokes them in turn, but I'm not sure that's the best way to do it. Following the Relay style and using a callback chain is another alternative, again possible with the current implementation.In either case, I'm wondering if this wouldn't be something useful to include in the core. Even if it's not, I'm curious as to what your thoughts are on either implementation strategy and whether there's a better way to go about this.