What is the best way to send multiple http request on a sequence?
I'll have to send some requests after a model is created.
I'm using a model observer for this.
I will send 4 - 6 request on some other endpoints. And all of them are different.
If one request fails, the next one will not execute. I feel like I'm into a trap.
public function created(Model $model){
$response1 = Http::withHeaders($headers)->post();
if($response1->ok){
$response2 = sendAnother();
}
}
public function sendAnother(){
return Http::withHeaders($headers)->post();
}
Is there any better way to do this. Again I'll have to send 4 - 6 delete requests when a model is deleted. Please show me some lights.
I am currently in the process of hosting a Laravel app that has functionalities from Vue and Blade for the frontend.
While I was able to host the application on Google App Engine along with creating a build process (I still have to set up the database), I found the whole process to be very tedious due to my lack of experience with hosting such apps on Google App Engine. Therefore, does anyone know of the cleanest method to host an app on Google App Engine?
$actions = [
function ($model) {
return Http::delete('https://test1.com/' . $model->id);
},
function ($model) {
return Http::delete('https://test2.com/' . $model->id);
},
//...
];
app(Pipeline::class)
->send($model)
->through(collect($actions)->map(function ($action) {
return function ($model, $next) use ($action) {
$response = $action($model);
// comment this condition if you don't want to stop further requests when one of the requests fails
if (!$response->ok()) {
return;
}
return $next($model);
};
})->all())
->thenReturn();