Initial commit, framework/frontend assets setup

This commit is contained in:
Maarten 2024-11-25 18:59:11 +01:00
commit 9d9858bb37
32 changed files with 4651 additions and 0 deletions

View 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());
}
}
}

View 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');
}
}