Skip to content

Commit

Permalink
Create validate config middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
bryceandy committed Jun 18, 2020
1 parent a484ee2 commit 588ff39
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/Http/Middleware/ValidateConfigMiddleware.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Bryceandy\Laravel_Pesapal\Http\Middleware;

use Bryceandy\Laravel_Pesapal\Exceptions\ConfigurationUnavailableException;
use Closure;

class ValidateConfigMiddleware
{
/**
* Ensures pesapal configurations are always available
* @param $request
* @param Closure $next
* @return mixed
* @throws ConfigurationUnavailableException
*/
public function handle($request, Closure $next)
{
if (!config('pesapal.consumer_key') ||
!config('pesapal.consumer_secret') ||
!config('pesapal.callback_url'))
throw new ConfigurationUnavailableException();

return $next($request);
}
}

0 comments on commit 588ff39

Please sign in to comment.