Closed Syn9673 closed 4 years ago
Hi Alexander, at the moment there are no ways you can unsubscribe a route once registered.
Regards
what if i add a "delete" array and then, if the array contains the url, just send a 404
Of course you add free to add this 404 behaviours on your application by using pre-processing middlewares. Then controlling the availability of routes before it reaches the router itself. I will try to make some time and implement a real delete route functionality inside of 0http and therefore in restana.
Regards
El mié., 15 abr. 2020 a las 10:30, Alexander9673 (notifications@github.com) escribió:
what if i add a "delete" array and then, if the array contains the url, just send a 404
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/jkyberneees/ana/issues/80#issuecomment-613897767, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA7IGXF4NAKSZLYQOXF3RPDRMVWCLANCNFSM4MHV4PDQ .
This is my implementation of it with pug.
if (!fileName)
fileName = req.url;
if (fileName === '/')
fileName = core.config.webserver.homepage;
try {
return core.pug.renderFile(`${core.dir}/contents/${fileName.endsWith('/')
? fileName.slice(1)
: fileName}.pug`, {
req,
res
})
} catch (e) {
if (e.code === 'ENOENT') {
if (req.getConfig().allowDebugging)
console.log(`Removed ${fileName} from routes, with method [GET]`);
return res.send(404);
}
}
that is in a function, which is used as a middleware
Is there a way to delete a route?