PHP code example of techworker / middleware
1. Go to this page and download the library: Download techworker/middleware 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/ */
techworker / middleware example snippets
use Psr7Middlewares\Middleware;
use Psr7Middlewares\Middleware\ErrorHandler;
use function Techworker\Functional\middleware;
/**
* This function checks whether the 'Authorization' is given.
*/
$middleware1 = function(
\Psr\Http\Message\ServerRequestInterface $request,
\Psr\Http\Message\ResponseInterface $response,
callable $next
) {
return $next($request, $response);
};
$middlewares = [$middleware1, \Psr7Middlewares\Middleware::uuid()];
middleware($request, $response, $middlewares);