Skip to content

Generate and use HTTP Middlewares classes implements with Psr

Notifications You must be signed in to change notification settings

effectra/http-middleware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 

Repository files navigation

Effectra Middleware

The effectra/http-server-middleware library provides middleware classes for handling HTTP requests and responses in server applications.

Installation

Install the library using Composer:

composer require effectra/http-middleware

Usage

Middleware Class

The Effectra\Http\Server\Middleware class is a base middleware class that implements the MiddlewareInterface. It provides a process method for processing the server request and returning the response.

use Effectra\Http\Server\Middleware;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;

class MyMiddleware extends Middleware implements MiddlewareInterface
{
    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        // Perform middleware logic here

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

        // Perform additional middleware logic here

        return $response;
    }
}

Contributing

Contributions are welcome! Please feel free to submit bug reports, feature requests, or pull requests.

License

This library is licensed under the MIT License.

Feel free to customize and enhance the README file to better suit your project's needs.