问题标签 [negroni]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
80 浏览

go - 用于公共和私有路由中间件的 httprouter 和 negroni

我很难理解如何一起使用 negroni 和 httprouter。

我有几条公共路线,例如/api/v1/ping

我有一堆需要认证中间件的私有路由,比如/api/v1/user

如果我希望所有路由都使用 negroni Common 中间件,但我只想将 auth 中间件和其他中间件应用于私有路由,我该如何设置?