is like this
url => => (DONE) or (NEXT) => (403) or (DONE)
meta information that can be set up for routing is inspired in vue-router
auth: true
you can know whether permission is required for this url.
but what should I do when I see that koa-router doesn"t have such a similar thing?
< hr >if it is vue-router "s idea, it should be like this
// "/"
{
path: "/",
name: "index",
meta:{
auth: true
}
}
router.beforeEach((to, from, next) => {
if ( to.meta.auth === true ){
// next
let miao = await XXX()
if ( miao === ){
next()
}else{
context.response.status = 403
return
}
}else{
next()
}
})