rosencrantz
rosencrantz copied to clipboard
Extensibility for Context object
Are there any thoughts for adding extensibility to the Context object? It would be handy to be able to attach information calculated in a Handler to the Context for a given request.
For simple Handler-s you can just write inline anonymous procs that have visibility to variables calculated in a containing scope, but there's not an (easy) way to do this with a Handler that is not inline. This is especially true if you have multiple things that are being calculated by various Handler-s.
Thanks
One thing that we may do is to change Context
to Context[A]
, where we add a field custom: A
, so that one can instantiate whatever context they like. The current context would then become Context[void]
, for which may add a type alias DefaultContext = Context[void]
.
Could this work for you? Do you have a concrete example where this necessity shows up, to better understand this use case?
That would be great. Being able to attach some application specific context would be useful.
Security is a primary example where this would be helpful, but other things like user preferences, etc. would also be handy to have in a context object once they have been looked up and/or calculated.
Thanks