Web_Crawler_API/app/Http/Controllers/WebCrawlController.php

40 lines
836 B
PHP

<?php
namespace App\Http\Controllers;
use App\Http\Requests\WebCrawlRequest;
use App\Services\WebCrawlerService;
class WebCrawlController extends Controller
{
protected $webCrawlerService;
public function __construct(WebCrawlerService $webCrawlerService)
{
$this->webCrawlerService = $webCrawlerService;
}
public function index()
{
return $this->webCrawlerService->getAllCrawls();
}
public function crawlWebsite(WebCrawlRequest $request)
{
$url = $request->query('url');
$depth = $request->query('depth', 0);
$refresh = $request->query('refresh', 0);
return $this->webCrawlerService->crawlWebsite($url, $depth, $refresh);
}
public function destroy($id)
{
return $this->webCrawlerService->deleteCrawl($id);
}
public function destroyAll()
{
return $this->webCrawlerService->deleteAllCrawls();
}
}