Skip to content

Latest commit

 

History

History
34 lines (25 loc) · 822 Bytes

SlimCallbackMiddleware.md

File metadata and controls

34 lines (25 loc) · 822 Bytes

SlimCallbackMiddleware

Methods

handle

<?php

use Chubbyphp\Framework\Middleware\SlimCallbackMiddleware;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
use Some\Psr7\ServerRequest;
use Some\Psr7\ResponseFactory;

$request = new ServerRequest();

$handler = new class() implements RequestHandlerInterface {
    public function handle(ServerRequestInterface $request): ResponseInterface
    {
        return new Response();
    }
};

$responseFactory = new ResponseFactory();

$callbackMiddleware = new SlimCallbackMiddleware(
    static fn (ServerRequestInterface $req, ResponseInterface $res, callable $next) => $next($req, $res),
    $responseFactory
);

$response = $callbackMiddleware->handle($request, $handler);