Pass original route option in server.rules() processor
- Dominant language
- JavaScript
- Stars
- 14.8k
- Forks
- 1.4k
- Avg merge
- 22d 3h
- Merged PRs (30d)
- 1
Description
## Support plan
* *is this issue currently blocking your project?* (yes/no): no
* *is this issue affecting a production system?* (yes/no): no
#### Context
* *node version*: 12
* *module version*: 19
* *environment* (e.g. node, browser, native): node
* *used with* (e.g. hapi application, another framework, standalone, ...): hapi pal
* *any other relevant information*:
#### What problem are you trying to solve?
- Would be nice if `server.rules()` could pass in original route config so that you can merge existing options with rules options.
- Would also be nice if there was an option to `merge` config and rules vs `applyToDefaults`
```js
const processor = (rules, { method, path, vhosts, config }) => {
const options = { tags: config.tags || [] }
if (rules.audit) {
options.tags = Hoek.merge(['audit'], options.tags)
}
if (rules.api) {
options.tags = Hoek.merge(['api'], options.tags)
}
}
```
#### Do you have a new or modified API suggestion to solve the problem?
https://github.com/hapijs/hapi/blob/master/lib/route.js#L68
```js
const rulesConfig = internals.rules(rules, { method, path, vhost, config }, server);
```
Contributor guide
Assessment
This issue has not been assessed yet.