I'd like to revisit the idea of passing in explicit contexts rather than relying on this pointers. Currently, if you want to have some global object available across a bunch of handlers split through files and plugins, your best bet is to use server.bind, but then every handler and extension method MUST use function rather than () =>. This is confusing and hard to communicate if your code base is split into several plugins and files.
I propose the handler and extension methods have an extra parameter passed into them (context) so that users can migrate away from relying on this and are free to use function or () => freely and interchangeably.
Your use case sounds like something where server.app is better used.
Note that I occasionally use bind to create a class instance in a plugin, and assign it's methods as handlers. Something I found rather useful.
I am looking for the cleanest way to pass the context in as an argument or property of an existing argument. Removing the actual bind is probably not a breaking change worth making.
Added as a second argument to server extensions, and as a property of the responder argument to all other bound handlers.
Ah, you just added a context as an alternative to using this. 馃憤
Most helpful comment
Added as a second argument to server extensions, and as a property of the
responderargument to all other bound handlers.