Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/effectra/http-middleware
Generate and use HTTP Middlewares classes implements with Psr
https://github.com/effectra/http-middleware
generate-class generated-code http middleware php psr-15
Last synced: 24 days ago
JSON representation
Generate and use HTTP Middlewares classes implements with Psr
- Host: GitHub
- URL: https://github.com/effectra/http-middleware
- Owner: effectra
- Created: 2023-05-13T11:35:47.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-06-19T18:31:41.000Z (over 1 year ago)
- Last Synced: 2024-12-09T22:17:57.682Z (about 1 month ago)
- Topics: generate-class, generated-code, http, middleware, php, psr-15
- Language: PHP
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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:
```bash
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.
```php
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](LICENSE).
Feel free to customize and enhance the README file to better suit your project's needs.