Laravel 5.7 + dingo/API 2.0 + tymon/jwt-auth 1.0.0-rc.3 問題

gxcnvip發表於2019-02-21

laravel 5.7 + dingo/api 2.0 + tymon/jwt-auth 1.0.0-rc.3 寫介面,請求介面時發現被請求了兩次,
//api 基礎型別
class ApiController extends BaseController
{
public $param;//接收的引數
public $perPage;//每頁數量
public $imageUrl;

public function construct($request){
parent::
construct();
$logger = new Logger('api-access-log');
$filename = env('API_LOG_PATH', '/data/logs/api/') . 'request-' . date('Ymd') . '.log';
$logger->pushHandler(new StreamHandler($filename, Logger::DEBUG));
$logInfo = ['url' => url()->current(), 'request' => request(), 'header' => '','t' => microtime(true)];
$logger->info('', $logInfo);
}
}

//api 控制器
class ExpressCompanyController extends ApiController
{
public function construct(Request $request)
{
parent::
construct($request);
}

public function index(){
//TODO
}
}

//路由
$api = app('Dingo\Api\Routing\Router');

$api->version('v1', function ($api) {
$api->group([
'prefix' => 'v1',
'namespace' => 'App\Modules\Api\Http\Controllers\v1',
'domain' => config('api.domain'),
'middleware'=> ['cors', 'check.api.parameter']
], function ($api) {
$api->get('/express/lists', 'ExpressCompanyController@index');
});
});

檢視日誌時發現寫了兩條,哪位大神知道原因嗎?

本作品採用《CC 協議》,轉載必須註明作者和本文連結

相關文章