File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed
Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change 1+ body {
2+ font-size : 18px ;
3+ }
4+
5+ p {
6+ line-height : 1.4 ;
7+ margin : 0 0 1em ;
8+ }
9+
10+ code {
11+ font-size : 17px ;
12+ }
13+
14+ li {
15+ margin : 0 0 5px ;
16+ }
17+
118.jumbotron {
219 text-align : center;
320 margin : 2em 0 ;
Original file line number Diff line number Diff line change @@ -75,6 +75,29 @@ <h2>Conventions</h2>
7575 < li > Take the decorated app as the first constructor argument</ li >
7676 < li > Decorate the handle call, delegate to the decorated app</ li >
7777 </ ul >
78+
79+ < p > A simple middleware could look like this:</ p >
80+ < pre > < code class ="php "> use Symfony\Component\HttpFoundation\Request;
81+ use Symfony\Component\HttpKernel\HttpKernelInterface;
82+
83+ class MyMiddleware implements HttpKernelInterface
84+ {
85+ protected $app;
86+
87+ public function __construct(HttpKernelInterface $app)
88+ {
89+ $this->app = $app;
90+ }
91+
92+ public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
93+ {
94+ $response = $this->app->handle($request, $type, $catch);
95+ $response->setContent($response->getContent() . "YOLO!");
96+
97+ return $response;
98+ }
99+ }</ code > </ pre >
100+
78101 < p >
79102 Yes, leveraging the HTTP abstraction is that easy!
80103 </ p >
You can’t perform that action at this time.
0 commit comments