I am building a RESTful API using expressJS, In my controller I have several functions like Chall_1, Chall_2,...
exports.validateChall_1 = function(res) {
//logic
res.json(1);
};
exports.validateChall_2 = function(res) {
res.json(2);
};
exports.validateChall_3 = function(res) {
res.json(3);
};
in my router.js I want to route the URL to a specific function based on challId which is a parameter in url
'use strict';
module.exports = function(app) {
var jsvalidator = require('../controllers/jsvalidatorController');
app.route('/chall/:challId')
.get(/*jsvalidator.validateChall_ + req.params.challId*/);
};
Is it possible to route directly to a specific function based on challId parameter?