PHP code example of darkorsa / cordo-gateway

1. Go to this page and download the library: Download darkorsa/cordo-gateway library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

darkorsa / cordo-gateway example snippets

 php


declare(strict_types=1);

namespace App;

use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Cordo\Gateway\Core\Application\Service\Register\RoutesRegister;

class UsersRoutes extends RoutesRegister
{
    public function register(): void
    {
        $this->router->addRoute(
            'GET',
            "/users",
            function (ServerRequestInterface $request, array $params): ResponseInterface {
                return $this->cacheRequest($request, '/users', 3600, []);
            }
        );

        $this->router->addRoute(
            'POST',
            "/users",
            function (ServerRequestInterface $request, array $params): ResponseInterface {
                return $this->sendRequest($request, '/users', []);
            }
        );
    }
}