Let's say that I have an endpoint in Laravel 5.3 routes\api.php defined as below:
Route::group(['middleware' => ['api.preprocess']], function () {
Route::post('/api/v1/notification', 'Api\v1\Controller@notificationPost');
Route::get('/notify/v1/notification', 'Api\v1\ApiController@notificationGet');
});
Inside of, my api.preprocess middleware group, I'd like to change the method used by the request from GET to POSTsomething like this:
public function handle($request, Closure $next)
{
if($request->some_var){
Route::setMethod('POST'); // pseudo code, but you get the idea
}
return $next($request);
}
Let's avoid an X Y problem. I have a working API with the above get and post routes. I need to call the POST endpoint of the API from a 3rd party system that only sends webhooks as GET requests.
My first thought is to simply create a middleware to detect the GET request from this service and simply update it to POST and send it on it's merry way through rest of the routing.
Can I do that? If so, how?
NOTE: I know how to update request input, I want to change the actual method
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire