<?php

use CodeIgniter\Router\RouteCollection;

/**
 * @var RouteCollection $routes
 */

//추가 Custom RULE 만들때 : ex)UUID형식
$routes->addPlaceholder('uuid', '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}');
//authFilter는 추가적인 작업이 필요
//1. app/Filters/AuthFilter.php
//2. Config/Filters.php -> $aliases = ['authFilter' => AuthFilter::class]
$routes->get('/', 'Home::index');
// $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'authFilter:manager'], function ($routes) {
$routes->group('admin', ['namespace' => 'App\Controllers\Admin'], function ($routes) {
    $routes->get('/', 'Home::index');
    $routes->group('user', function ($routes) {
        $routes->get('/', 'UserController::index');
    });
    $routes->group('cloudflare', ['namespace' => 'App\Controllers\Admin\Cloudflare'], function ($routes) {
        $routes->group('account', function ($routes) {
            $routes->get('/', 'AccountController::index');
            $routes->get('create', 'AccountController::create_form');
            $routes->post('create', 'AccountController::create');
        });
        $routes->group('zone', function ($routes) {
            $routes->get('/', 'ZoneController::index');
            $routes->post('create/(:uuid)', 'RecordController::create/$1');
        });
        $routes->group('record', function ($routes) {
            $routes->get('/', 'RecordController::index');
            $routes->post('create/(:uuid)', 'RecordController::create/$1');
        });
    });
});

