javascript - Practice for Routing Handler in MEAN Stack? -


i have application on express 4.x integrated twilio api , dependent on input users' phone, respond different xml files may or may not created dynamically.

where supposed put theoretical route conditional? i.e.

exports.handle = function(req, res) {     if(req.body.digits == 1){           //pass first option handler      }     if (req.body.digits == 2) {          //create xml file dynamically          //for second option      }    else {           //handle else     } }; 

it seems bit heavy putting routes file. in such mvc structure typical put conditional controller? or stuff routes? or there option i'm unaware of?

i'd rather have code pass requests single handler. i.e.

exports.handle = function(req, res) {   if (req.body.digits)        //send handler }; 

where go? called?

in scenario, router "single handler". channeling input through routing mechanism , letting decide appropriate handler (or controller) is. commonly referred "front controller". makes sense put logic handler in file referencing if architect software in mind.


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -