Initial commit, framework/frontend assets setup
This commit is contained in:
commit
9d9858bb37
32 changed files with 4651 additions and 0 deletions
39
app/Controllers/Api/SubnetController.php
Normal file
39
app/Controllers/Api/SubnetController.php
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controllers\Api;
|
||||
|
||||
use App\Services\Subnet;
|
||||
use Core\Controllers\Controller;
|
||||
use Core\View\Render;
|
||||
use Exception;
|
||||
|
||||
class SubnetController extends Controller
|
||||
{
|
||||
/**
|
||||
* Get all subnet data
|
||||
*
|
||||
* @return \Core\View\Render
|
||||
*/
|
||||
public function data(): Render
|
||||
{
|
||||
// Get the user input
|
||||
$subnet = $this->request->get('subnet', '');
|
||||
|
||||
try {
|
||||
// Validate the input
|
||||
if (!str_contains($subnet, '/')) {
|
||||
throw new Exception('Invalid subnet format.');
|
||||
}
|
||||
|
||||
// Delegate calculation to subnet service
|
||||
$subnetInfo = Subnet::calculate($subnet);
|
||||
|
||||
return $this->response->json()
|
||||
->with('result', $subnetInfo);
|
||||
} catch (Exception $e) {
|
||||
return $this->response->status(403)
|
||||
->json()
|
||||
->with('message', $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
19
app/Controllers/HomeController.php
Normal file
19
app/Controllers/HomeController.php
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use Core\Controllers\Controller;
|
||||
use Core\View\Render;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
/**
|
||||
* Render index
|
||||
*
|
||||
* @return \Core\View\Render
|
||||
*/
|
||||
public function index(): Render
|
||||
{
|
||||
return $this->response->view('subnet');
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue