How to redirect one version of url to another in express node.js -


i have following implementation done

app.post('/k/v4/monitor/start', function (req, res) {       monitor.start(data, function (err) {             res.end('monitor started');       }); });  app.post('/k/v4/monitor/stop', function (req, res) {       monitor.start(data, function (err) {             res.end('monitor stopped');       }); }); 

now requirement need support few older version (1 3) , redirect version 4. means /k/v1/monitor/, /k/v2/monitor/, /k/v3/monitor/* urls should redirected /k/v4/monitor/*.

how handle such case of routing in express? best possible ways achieve this? if can provide me example great.

i guess use http redirects:

app.post('/k/v1/monitor/start', function(req, res) {     res.writeheader(301, { 'location' : '/k/v4/monitor/start'});     res.end(); }) 

but understood problem post request changed upon redirect. don't know if can use solution. or maybe don't need use http post @ all, can use http (it mean using app.get instead of app.post related urls) ....


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -