Prerequisites
🚀 Feature Proposal
When registering a plugin, you can currently pass a prefix that apply to all routes in the plugin. It'd be awesome to have that same functionality, but with a version or host constraint instead of a path prefix. I don't believe there is a simple way to do this at the moment without manually passing through options to every route, but I'd love to be wrong!
Motivation
We have a few subdomain specific APIs within our app, so rather than manually passing through options to the plugin and then passing them into each route within the plugin, it'd be really nice to simply set a constraint when registering the plugin itself and have all the routes within the plugin inherit it.
Example
fastify.register(require('./routes/v1/users'), { prefix: '/v1' }) // currently supported
fastify.register(require('./routes/v1/users'), { constraints: { host: 'auth.fastify.io' } }) // not supported
fastify.register(require('./routes/apple'), { constraints: { host: 'apple.fastify.io' } })
fastify.register(require('./routes/berry'), { constraints: { host: 'berry.fastify.io' } })
GET https://apple.fastify.io/
200 => I LOVE APPLES
GET https://berry.fastify.io/
200 => I LOVE BERRIES
Prerequisites
🚀 Feature Proposal
When registering a plugin, you can currently pass a prefix that apply to all routes in the plugin. It'd be awesome to have that same functionality, but with a version or host constraint instead of a path prefix. I don't believe there is a simple way to do this at the moment without manually passing through options to every route, but I'd love to be wrong!
Motivation
We have a few subdomain specific APIs within our app, so rather than manually passing through options to the plugin and then passing them into each route within the plugin, it'd be really nice to simply set a constraint when registering the plugin itself and have all the routes within the plugin inherit it.
Example