[英]How to delete all/some restify routes and add new
I have a JSON config file which specifies API end-points. 我有一个JSON配置文件,用于指定API端点。 I read it on app load and iterate through its keys, like this
我在应用程序加载时读取它,并通过其键进行迭代,如下所示
server[type](config.path, function (req, res, next) {
});
Now, I am looking for a way to remove that route from server. 现在,我正在寻找一种从服务器删除该路由的方法。 I mean delete the API I just created.
我的意思是删除我刚刚创建的API。 Is there any way by which it can be done?
有什么办法可以做到? I checked the docs but couldn't find anything related to this.
我检查了文档,但找不到与此相关的任何内容。
I tried removing keys in server.routes
. 我尝试删除
server.routes
密钥。 But it creates new keys with different name and I am not sure why it creates. 但是它会创建具有不同名称的新密钥,我不确定为什么会创建它。 for example if I delete a route
getusers
from server.routes
, a new key is created like server.routes.getusers234234
(some random number appended). 例如,如果我从
server.routes
删除路由getusers
,则会创建一个新密钥,如server.routes.getusers234234
(附加一些随机数)。
我相信,在Restify中删除路由的最佳方法是扫描server.routes.mounts
以查找要删除的任何路由,然后将每个路由对象传递给server.rm
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.