💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、豆包、星火、月之暗面及文生图、文生视频 广告
[TOC] ### Koa2 中使用路由中间件 ~~~ // 定义鉴权中间件 const auth = async (ctx, next) => { if (ctx.url !== '/posts') { ctx.throw('没有权限访问!') await next() } } // 路由中使用中间件 PostsRouter.get('/', auth, (ctx, next) => { ctx.body = { name: '首页' } }) ~~~