@@ -47,7 +47,8 @@ discard block |
||
| 47 | 47 | { |
| 48 | 48 | $core = $this->getCore(); |
| 49 | 49 | |
| 50 | - $core->setHandler(function () { |
|
| 50 | + $core->setHandler(function () |
|
| 51 | + { |
|
| 51 | 52 | return 'hello world'; |
| 52 | 53 | }); |
| 53 | 54 | |
@@ -69,7 +70,8 @@ discard block |
||
| 69 | 70 | { |
| 70 | 71 | $core = $this->getCore(); |
| 71 | 72 | $core->setHandler( |
| 72 | - new CallableHandler(function () { |
|
| 73 | + new CallableHandler(function () |
|
| 74 | + { |
|
| 73 | 75 | return 'hello world'; |
| 74 | 76 | }, new ResponseFactory(new HttpConfig(['headers' => []]))) |
| 75 | 77 | ); |
@@ -82,7 +84,8 @@ discard block |
||
| 82 | 84 | { |
| 83 | 85 | $core = $this->getCore(); |
| 84 | 86 | |
| 85 | - $core->setHandler(function ($req, $resp) { |
|
| 87 | + $core->setHandler(function ($req, $resp) |
|
| 88 | + { |
|
| 86 | 89 | return $resp->withAddedHeader('hello', 'value'); |
| 87 | 90 | }); |
| 88 | 91 | |
@@ -95,7 +98,8 @@ discard block |
||
| 95 | 98 | { |
| 96 | 99 | $core = $this->getCore(); |
| 97 | 100 | |
| 98 | - $core->setHandler(function ($req, $resp) { |
|
| 101 | + $core->setHandler(function ($req, $resp) |
|
| 102 | + { |
|
| 99 | 103 | echo 'hello!'; |
| 100 | 104 | |
| 101 | 105 | return $resp->withAddedHeader('hello', 'value'); |
@@ -111,7 +115,8 @@ discard block |
||
| 111 | 115 | { |
| 112 | 116 | $core = $this->getCore(); |
| 113 | 117 | |
| 114 | - $core->setHandler(function ($req, $resp) { |
|
| 118 | + $core->setHandler(function ($req, $resp) |
|
| 119 | + { |
|
| 115 | 120 | echo 'hello!'; |
| 116 | 121 | $resp->getBody()->write('world '); |
| 117 | 122 | |
@@ -128,7 +133,8 @@ discard block |
||
| 128 | 133 | { |
| 129 | 134 | $core = $this->getCore(); |
| 130 | 135 | |
| 131 | - $core->setHandler(function () { |
|
| 136 | + $core->setHandler(function () |
|
| 137 | + { |
|
| 132 | 138 | ob_start(); |
| 133 | 139 | ob_start(); |
| 134 | 140 | echo 'hello!'; |
@@ -149,7 +155,8 @@ discard block |
||
| 149 | 155 | { |
| 150 | 156 | $core = $this->getCore(); |
| 151 | 157 | |
| 152 | - $core->setHandler(function () { |
|
| 158 | + $core->setHandler(function () |
|
| 159 | + { |
|
| 153 | 160 | return [ |
| 154 | 161 | 'status' => 404, |
| 155 | 162 | 'message' => 'not found', |
@@ -165,7 +172,8 @@ discard block |
||
| 165 | 172 | { |
| 166 | 173 | $core = $this->getCore(); |
| 167 | 174 | |
| 168 | - $core->setHandler(function () { |
|
| 175 | + $core->setHandler(function () |
|
| 176 | + { |
|
| 169 | 177 | return new Json([ |
| 170 | 178 | 'status' => 404, |
| 171 | 179 | 'message' => 'not found', |
@@ -181,7 +189,8 @@ discard block |
||
| 181 | 189 | { |
| 182 | 190 | $core = $this->getCore([HeaderMiddleware::class]); |
| 183 | 191 | |
| 184 | - $core->setHandler(function () { |
|
| 192 | + $core->setHandler(function () |
|
| 193 | + { |
|
| 185 | 194 | return 'hello?'; |
| 186 | 195 | }); |
| 187 | 196 | |
@@ -198,7 +207,8 @@ discard block |
||
| 198 | 207 | $core->getPipeline()->pushMiddleware(new Header2Middleware()); |
| 199 | 208 | $core->getPipeline()->riseMiddleware(new HeaderMiddleware()); |
| 200 | 209 | |
| 201 | - $core->setHandler(function () { |
|
| 210 | + $core->setHandler(function () |
|
| 211 | + { |
|
| 202 | 212 | return 'hello?'; |
| 203 | 213 | }); |
| 204 | 214 | |
@@ -215,7 +225,8 @@ discard block |
||
| 215 | 225 | $core->getPipeline()->pushMiddleware(new HeaderMiddleware()); |
| 216 | 226 | $core->getPipeline()->riseMiddleware(new Header2Middleware()); |
| 217 | 227 | |
| 218 | - $core->setHandler(function () { |
|
| 228 | + $core->setHandler(function () |
|
| 229 | + { |
|
| 219 | 230 | return 'hello?'; |
| 220 | 231 | }); |
| 221 | 232 | |
@@ -253,7 +264,8 @@ discard block |
||
| 253 | 264 | |
| 254 | 265 | $core = $this->getCore(); |
| 255 | 266 | |
| 256 | - $core->setHandler(function () { |
|
| 267 | + $core->setHandler(function () |
|
| 268 | + { |
|
| 257 | 269 | return 'hello world'; |
| 258 | 270 | }); |
| 259 | 271 | |
@@ -274,7 +286,8 @@ discard block |
||
| 274 | 286 | $tracerFactory = m::mock(TracerFactoryInterface::class), |
| 275 | 287 | ); |
| 276 | 288 | |
| 277 | - $http->setHandler(function () { |
|
| 289 | + $http->setHandler(function () |
|
| 290 | + { |
|
| 278 | 291 | return 'hello world'; |
| 279 | 292 | }); |
| 280 | 293 | |
@@ -309,7 +322,8 @@ discard block |
||
| 309 | 322 | TraceKind::SERVER, |
| 310 | 323 | ) |
| 311 | 324 | ->willReturnCallback( |
| 312 | - function ($name, $callback, $attributes, $scoped, $traceKind) { |
|
| 325 | + function ($name, $callback, $attributes, $scoped, $traceKind) |
|
| 326 | + { |
|
| 313 | 327 | self::assertIsString($attributes['http.url']); |
| 314 | 328 | return $this->container |
| 315 | 329 | ->get(TracerInterface::class) |
@@ -335,7 +349,8 @@ discard block |
||
| 335 | 349 | $tracerFactory, |
| 336 | 350 | ); |
| 337 | 351 | |
| 338 | - $http->setHandler(function () { |
|
| 352 | + $http->setHandler(function () |
|
| 353 | + { |
|
| 339 | 354 | return 'hello world'; |
| 340 | 355 | }); |
| 341 | 356 | |
@@ -356,7 +371,8 @@ discard block |
||
| 356 | 371 | $tracerFactory = m::mock(TracerFactoryInterface::class), |
| 357 | 372 | ); |
| 358 | 373 | |
| 359 | - $http->setHandler(function () { |
|
| 374 | + $http->setHandler(function () |
|
| 375 | + { |
|
| 360 | 376 | return 'hello world'; |
| 361 | 377 | }); |
| 362 | 378 | |
@@ -368,7 +384,8 @@ discard block |
||
| 368 | 384 | $tracer |
| 369 | 385 | ->shouldReceive('trace') |
| 370 | 386 | ->once() |
| 371 | - ->andReturnUsing(function($name, $callback, $attributes, $scoped, $traceKind) { |
|
| 387 | + ->andReturnUsing(function($name, $callback, $attributes, $scoped, $traceKind) |
|
| 388 | + { |
|
| 372 | 389 | return $this->container->get(TracerInterface::class)->trace($name, $callback, $attributes, $scoped, $traceKind); |
| 373 | 390 | }); |
| 374 | 391 | |
@@ -34,7 +34,8 @@ discard block |
||
| 34 | 34 | ?TracerFactoryInterface $tracerFactory = null, |
| 35 | 35 | private readonly ?EventDispatcherInterface $dispatcher = null, |
| 36 | 36 | ) { |
| 37 | - foreach ($this->config->getMiddleware() as $middleware) { |
|
| 37 | + foreach ($this->config->getMiddleware() as $middleware) |
|
| 38 | + { |
|
| 38 | 39 | $this->pipeline->pushMiddleware($this->container->get($middleware)); |
| 39 | 40 | } |
| 40 | 41 | |
@@ -66,7 +67,8 @@ discard block |
||
| 66 | 67 | |
| 67 | 68 | $this->dispatcher?->dispatch(new RequestReceived($request)); |
| 68 | 69 | |
| 69 | - if ($this->handler === null) { |
|
| 70 | + if ($this->handler === null) |
|
| 71 | + { |
|
| 70 | 72 | throw new HttpException('Unable to run HttpCore, no handler is set.'); |
| 71 | 73 | } |
| 72 | 74 | |
@@ -103,7 +105,8 @@ discard block |
||
| 103 | 105 | traceKind: TraceKind::SERVER, |
| 104 | 106 | ); |
| 105 | 107 | |
| 106 | - foreach ($tracer->getContext() as $key => $value) { |
|
| 108 | + foreach ($tracer->getContext() as $key => $value) |
|
| 109 | + { |
|
| 107 | 110 | $response = $response->withHeader($key, $value); |
| 108 | 111 | } |
| 109 | 112 | |