first commit
This commit is contained in:
21
app/Http/Controllers/LookupController.php
Normal file
21
app/Http/Controllers/LookupController.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Cache;
|
||||
use App\Services\BookInformation\GoogleBooks;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
|
||||
class LookupController {
|
||||
public function lookup($isbn) {
|
||||
if (!preg_match('/^(\d+)$/', $isbn)) {
|
||||
throw new HttpException(400);
|
||||
}
|
||||
|
||||
return Cache::remember('isbn_' . $isbn, 1440, function() use ($isbn) {
|
||||
$google_books = new GoogleBooks();
|
||||
|
||||
return $google_books->lookup($isbn);
|
||||
});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user