hakone / middleware-dispatcher
A lightweight PSR-15 middleware dispatcher
Installs: 1 131
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=7.3
- hakone/untouchable-psr7: ^0.2.0
- psr/http-server-middleware: ^1.0
Requires (Dev)
- nyholm/psr7: ^1.5
- nyholm/psr7-server: ^1.0
- phpstan/phpstan: ^1.10
- phpstan/phpstan-phpunit: ^1.3
- phpstan/phpstan-strict-rules: ^1.5
- phpunit/phpunit: ^9.6
- symplify/easy-coding-standard: ^11.2
This package is auto-updated.
Last update: 2024-12-04 12:38:50 UTC
README
Hakone is a lightweight PSR-15 middleware dispatcher implementation. It is inspired by Relay.
Concept
The PSR-15 is designed to be general purpose middleware. All middleware can intervene in both requests and responses.
Hakone is a "queue-based request handler" described in PSR-15 Meta Document. The downside of queue-based is that the more middleware you have, the more stack traces will pile up.
We've written a number of small-duty middlewares, but for many use cases they only do work on either the request or the response. We decided to classify the types of middleware into three types: "request interceptor", "general-purpose middleware" and "response decorator".
How to use
$dispatcher = Hakone\relay([ 'interceptors' => [ // ... ], 'middlewares' => [ // ... ], 'handler' => $handler 'decorators' => [ // ... ], ]);
Copyright
Copyright 2023 USAMI Kenta <tadsan@zonu.me>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.