前缀express.js路由 [英] Prefix express.js Routes

查看:195
本文介绍了前缀express.js路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在express.js中是否可以为路由的子集添加前缀?我知道您可以在调用app.router()时添加安装点,但这会影响所有路由.

Is there a way to prefix a subset of routes in express.js? I know that you can add a mount point when calling the app.router() but this affects all routes.

我正在寻找一种将/api/v1/添加到一堆路由的方法,而不是将其应用于每个路由定义.

I am looking for a way to add /api/v1/ to a bunch of routes instead of applying this to every single route definition.

推荐答案

express-namespace 确实你想要什么.

这篇关于前缀express.js路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆