webman api 統(tǒng)一返回
像直接使用
$this->success();
$this->error();
這樣
有些接口需要登陸才能調(diào)用
有些接口不用登陸調(diào)用
這種大家是怎么設(shè)計(jì)的
中間件設(shè)置路由白名單 我是這么做的
// 白名單
$apiWhite=[
'/api/user/login',
'/api/user/register',
'/api/user/captcha',
];
$path=$request->path();
// 如果是白名單則放行
if(in_array($path,$apiWhite)){
return $handler($request);
}
下面就是需要去登錄的token判斷
認(rèn)證插件:http://wtbis.cn/plugin/10
權(quán)限控制插件:http://wtbis.cn/plugin/6