11# Middleware
22
3- the psr-15 HTTP Middleware implement.
3+ The psr-15 HTTP Middleware implement.
44
5- ref https://github.com/php-fig/fig-standards/blob/master/proposed/http- handlers/middleware .md
5+ ref [ PSR 15 ] ( https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-15-request- handlers.md )
66
77
88## 项目地址
@@ -129,24 +129,24 @@ n after >>>
129129response content: node 4 + node 3 + node 2 + node 1
130130```
131131
132- ### 一个基于中间件的应用
132+ ## 一个基于中间件的应用示例
133133
134- - 引入相关类
134+ ### 引入相关类
135135
136136路由器,psr 7的http message 库
137137
138138``` php
139139use Inhere\Http\HttpFactory;
140- use Inhere\Library\Helpers\ Http;
140+ use Inhere\Http\HttpUtil ;
141141use Inhere\Middleware\MiddlewareStackAwareTrait;
142- use Inhere\Middleware\RequestHandlerInterface ;
142+ use Inhere\Route\Base\RouterInterface ;
143143use Inhere\Route\ORouter;
144- use Inhere\Route\RouterInterface;
145144use Psr\Http\Message\ResponseInterface;
146145use Psr\Http\Message\ServerRequestInterface;
146+ use Psr\Http\Server\RequestHandlerInterface;
147147```
148148
149- - 创建一个应用类
149+ ### 创建一个应用类
150150
151151``` php
152152
@@ -206,7 +206,7 @@ $app = new class implements RequestHandlerInterface {
206206};
207207```
208208
209- - 创建路由器并注册路由
209+ ### 创建路由器并注册路由
210210
211211``` php
212212$router = new ORouter();
@@ -224,7 +224,7 @@ $router->get('/hello/{name}', function ($args) {
224224
225225```
226226
227- - 添加中间件
227+ ### 添加中间件
228228
229229``` php
230230/**
@@ -247,7 +247,7 @@ $app->use(function (ServerRequestInterface $request, RequestHandlerInterface $ha
247247});
248248```
249249
250- - 准备运行
250+ ### 准备运行
251251
252252``` php
253253/**
@@ -259,7 +259,7 @@ $app->setRouter($router);
259259$app->run($req);
260260```
261261
262- - 运行server
262+ ### 运行dev server
263263
264264``` bash
265265$ php -S 127.0.0.1:8009 examples/app.php
0 commit comments