Hi guys,
I've been learning Laravel since 5.0 but then I had left programming work for sometime now so I was kind of forgot everything about Laravel. I'm now in the process of learning it again using Laravel 5.1 and I need your help to refresh my memory.
So basically I want to create some article publishing panel, let say for example it will post to a Wordpress blog using API (XMLRPC or manually build the request (curl: login -> new post -> etc.)? ). I will "register" these "API" url into my panel, and I will have input fields to fill the article contents and other necessary data. Basically it will call Route::('posttoblog', 'PostController@submit') , the problem here is that I don't even know if the "API" url is even up, so I'm about to create some mechanism to check it even before the "input fields" data reached the PostController. I have an idea to check the "API" url via a Middleware, something like:
public function handle($request, Closure $next)
{
if( ! is_api_url_online($request->api_url))
return redirect()->back()->with('status', 'The API URL is down, article submission aborted');
return $next($request); // let the PostController@submit do the job.
}
And yeah I think it will definitely work, but can anyone suggest me a better approach?