lundi 28 novembre 2016

Redirect a route in Laravel 5.3

Im building an API in Laravel 5.3. In my routes/api.php file I have 3 endpoints:

Route::post('/notify/v1/notifications', 'Api\Notify\v1\NotifyApiController@notificationsPost');

Route::post('/notify/v1/alerts', 'Api\Notify\v1\NotifyApiController@alertsPost');

Route::post('/notify/v1/incidents', 'Api\Notify\v1\NotifyApiController@incidentsPost');

Several services will call these routes directly, however, when a request comes in from some services, the input data needs to be processed before it can hit these endpoints.

For example, if a request comes in from JIRA, I need to process the input before it hits these endpoints.

Im thinking that the simplest way to do this would be to have a 4th endpoint like the below:

Route::post('/notify/v1/jira', 'Api\Notify\v1\JiraFormatter@formatJiraPost');

The idea being to hit the /notify/v1/jira endpoint, have the formatJiraPost method process the input and then forward the request to /notify/v1/notifications (/alerts, /incidents) as required.

How can I have the /notify/v1/jira endpoint forward the request to the /notify/v1/notifications endpoint?

Do you see a better way to do this?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2fWMr16
via IFTTT

Aucun commentaire:

Enregistrer un commentaire