Open damusix opened 4 years ago
I started digging into this. One thing that makes this less straightforward than one might hope is that there are several levels of defaults that can be applied to the route config. That can be seen here:
https://github.com/hapijs/hapi/blob/c2107e9bc9c522c3778e90a3629a0c84f776f9fe/lib/route.js#L81-L83
So if we were to pass the route config into the rule, we'd need to consider which of the intermediate route configs ought to be passed. For example, server route defaults will be applied on top of the user's supplied route config prior to defaults from the rules processor. I believe this is why currently route.options.rules
is isolated and passed on its own, to sidestep this awkward issue of working with un-finalized route configurations as various defaults are applied. This would also need to work consistently when a route has multiple rules processors. I am not sure I made this super clear— does that make sense? Any suggestions how it might be addressed?
Support plan
Context
What problem are you trying to solve?
server.rules()
could pass in original route config so that you can merge existing options with rules options.merge
config and rules vsapplyToDefaults
Do you have a new or modified API suggestion to solve the problem?
https://github.com/hapijs/hapi/blob/master/lib/route.js#L68