@mgaussie
Here you have your middleware to do what you need. You can set your conditions to differentiate services and functions(cars and toys) and location(colours).
This only covers simple layout+content pages so if you have SCs associated to layouts or content pages you need to add more cases(thus my comment of ending with a fork of /lib/setup/routes.js
.
But hopefully it sets you on the right track if you really really need this.
const { templateView } = require('../../../lib/core/middleware');
exports.handler = function (app) {
const cars = ['ford', 'seat', 'toyota']
const toys = ['ball', 'frisbee', 'stick']
const colours = ['blue', 'red', 'green']
app.get('/:param1/:param2/', (req, res) => {
if (colours.includes(req.params.param2)) {
if (cars.includes(req.params.param1))
templateView('test', 'cars', {}, [])(req, res)
else if (toys.includes(req.params.param1))
templateView('test', 'toys', {}, [])(req, res)
else
res.send('This neither a car nor a toy');
}
else
res.send('This is not a valid colour');
});
}
Edit: I’ve taken the freedom to move this from the bug category to the how-to in extensions as it’s wasn’t a bug at the moment but had no solution without custom middleware.