如何向 Lumen 中的路由添加查询参数?
How to add query parameter to routes in Lumen?
我想知道如何向 Lumen 中的路由添加查询参数
这是我创建的路线示例
$app->get('/product/{apikey}','ProductController@getProduct');
这在我使用
时有效
但我想这样使用它
我试过了
$app->get('/product/?apikey={apikey}','ProductController@getProduct');
但这给了我 MethodNotAllowedHttpException
我想知道如何在 Lumen 中编写带有查询参数的路由?
就这样:
$app->get('/product','ProductController@getProduct');
并使用:
$request->get('apikey')
在 ProductController@getProduct
函数中。
(也就是说,验证 API 密钥最好通过中间件完成...)
我想知道如何向 Lumen 中的路由添加查询参数
这是我创建的路线示例
$app->get('/product/{apikey}','ProductController@getProduct');
这在我使用
时有效但我想这样使用它
我试过了
$app->get('/product/?apikey={apikey}','ProductController@getProduct');
但这给了我 MethodNotAllowedHttpException
我想知道如何在 Lumen 中编写带有查询参数的路由?
就这样:
$app->get('/product','ProductController@getProduct');
并使用:
$request->get('apikey')
在 ProductController@getProduct
函数中。
(也就是说,验证 API 密钥最好通过中间件完成...)