Couldn't find anything that specifically matches my situation. I have a route group defined as:
Route::group(['prefix' => 'api/v1/{access_token}'], function(){
...
}
The above group has several resource routes inside. I am trying to create a custom middleware that will validate the access_token
parameter and return a 400 response if the parameter is not valid. I would like to be able to so something like this in my controllers:
class ProductController extends Controller {
/**
* Instantiate a new ProductController
*/
public function __construct()
{
$this->middleware('verifyAccessToken');
}
...
}
My question is not "how do I define custom middleware", but rather, how can I gain access to the access_token
parameter from within the handle
function of my custom middleware?
EDIT: While the question suggested as a duplicate is similar and has an answer, that answer seems to be outdated and/or unsatisfactory for what I am trying to accomplish.