hakone/middleware-dispatcher

轻量级PSR-15中间件分发器

0.1.0 2023-03-09 18:04 UTC

This package is auto-updated.

Last update: 2024-09-04 12:07:57 UTC


README

Hakone是一个轻量级的PSR-15中间件分发器实现。它受到Relay的启发。

概念

PSR-15旨在设计成通用中间件。所有中间件都可以在请求和响应中干预。

Hakone是PSR-15元文档中描述的“基于队列的请求处理器”。基于队列的缺点是,中间件越多,堆栈跟踪就越堆叠。

我们编写了多个小任务中间件,但许多情况下它们仅在请求或响应上执行工作。我们决定将中间件类型分为三类:“请求拦截器”“通用中间件”“响应装饰器”

如何使用

$dispatcher = Hakone\relay([
    'interceptors' => [
        // ...
    ],
    'middlewares' => [
        // ...
    ],
    'handler' => $handler
    'decorators' => [
        // ...
    ],
]);

版权

Copyright 2023 USAMI Kenta <[email protected]>

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.