Skip to content

Commit a70394d

Browse files
committed
update readme
1 parent 2cd374e commit a70394d

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
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 >>>
129129
response 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
139139
use Inhere\Http\HttpFactory;
140-
use Inhere\Library\Helpers\Http;
140+
use Inhere\Http\HttpUtil;
141141
use Inhere\Middleware\MiddlewareStackAwareTrait;
142-
use Inhere\Middleware\RequestHandlerInterface;
142+
use Inhere\Route\Base\RouterInterface;
143143
use Inhere\Route\ORouter;
144-
use Inhere\Route\RouterInterface;
145144
use Psr\Http\Message\ResponseInterface;
146145
use 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

example/app.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,16 @@
99
use Inhere\Http\HttpFactory;
1010
use Inhere\Http\HttpUtil;
1111
use Inhere\Middleware\MiddlewareStackAwareTrait;
12-
use Psr\Http\Server\RequestHandlerInterface;
13-
use Inhere\Route\ORouter;
1412
use Inhere\Route\Base\RouterInterface;
13+
use Inhere\Route\ORouter;
1514
use Psr\Http\Message\ResponseInterface;
1615
use Psr\Http\Message\ServerRequestInterface;
16+
use Psr\Http\Server\RequestHandlerInterface;
1717

1818
require dirname(__DIR__) . '/../../autoload.php';
1919

20-
$app = new class implements RequestHandlerInterface {
20+
$app = new class implements RequestHandlerInterface
21+
{
2122
use MiddlewareStackAwareTrait;
2223

2324
/**
@@ -78,7 +79,7 @@ public function setRouter(RouterInterface $router)
7879
* add routes
7980
*/
8081
$router->get('/', function () {
81-
echo 'hello, world';
82+
echo 'hello, world';
8283
});
8384

8485
$router->get('/hello/{name}', function ($args) {

src/MiddlewareStackAwareTrait.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ public function callStack(ServerRequestInterface $request)
102102
*/
103103
public function handle(ServerRequestInterface $request): ResponseInterface
104104
{
105-
// $handler = $this;
106105
// $handler = clone $this;
107106

108107
// IMPORTANT: if no middleware. this is end point of the chain.

0 commit comments

Comments
 (0)