@@ -101,7 +101,7 @@ |
||
101 | 101 | { |
102 | 102 | // ensure a default for 'uSilex.responseEmitter' |
103 | 103 | if (!isset($this['uSilex.responseEmitter'])) { |
104 | - $this['uSilex.responseEmitter'] = $this->protect(function () { |
|
104 | + $this['uSilex.responseEmitter'] = $this->protect(function() { |
|
105 | 105 | }); |
106 | 106 | } |
107 | 107 |
@@ -49,13 +49,13 @@ |
||
49 | 49 | */ |
50 | 50 | public function register(Container $app) |
51 | 51 | { |
52 | - $app['piper'] = function () { |
|
52 | + $app['piper'] = function() { |
|
53 | 53 | return new MiddlewarePipe(); |
54 | 54 | }; |
55 | 55 | |
56 | 56 | $app['handler.queue'] = []; |
57 | 57 | |
58 | - $app['uSilex.httpHandler'] = function ($app) { |
|
58 | + $app['uSilex.httpHandler'] = function($app) { |
|
59 | 59 | $piper = $app['piper']; |
60 | 60 | foreach ($app['handler.queue'] as $middlewareService) { |
61 | 61 | $piper->pipe($app[$middlewareService]); |
@@ -45,8 +45,8 @@ |
||
45 | 45 | { |
46 | 46 | $app['handler.queue'] = []; |
47 | 47 | |
48 | - $app['uSilex.httpHandler'] = function ($app) { |
|
49 | - $resolver = function ($entry) use ($app) { |
|
48 | + $app['uSilex.httpHandler'] = function($app) { |
|
49 | + $resolver = function($entry) use ($app) { |
|
50 | 50 | return is_string($entry) ? $app[$entry] : $entry; |
51 | 51 | }; |
52 | 52 |
@@ -47,15 +47,15 @@ |
||
47 | 47 | */ |
48 | 48 | public function register(Container $app) |
49 | 49 | { |
50 | - $app['uSilex.request'] = function () { |
|
50 | + $app['uSilex.request'] = function() { |
|
51 | 51 | return ServerRequestFactory::fromGlobals(); |
52 | 52 | }; |
53 | 53 | |
54 | - $app['uSilex.responseEmitter'] = $app->protect(function ($response) { |
|
54 | + $app['uSilex.responseEmitter'] = $app->protect(function($response) { |
|
55 | 55 | (new SapiEmitter())->emit($response); |
56 | 56 | }); |
57 | 57 | |
58 | - $app['uSilex.exceptionHandler'] = $app->protect(function ($e, $app) { |
|
58 | + $app['uSilex.exceptionHandler'] = $app->protect(function($e, $app) { |
|
59 | 59 | $exceptionData = new \StdClass(); |
60 | 60 | $exceptionData->code = $e->getCode(); |
61 | 61 | $exceptionData->message = $e->getMessage(); |
@@ -22,7 +22,7 @@ |
||
22 | 22 | $app = new Application; |
23 | 23 | $app->register(new Psr15Provider()); |
24 | 24 | $app->register(new Psr7Provider()); |
25 | -$app['myMiddleware'] = function ($app) { |
|
25 | +$app['myMiddleware'] = function($app) { |
|
26 | 26 | return new MyMiddleware($app); |
27 | 27 | }; |
28 | 28 | $app['message'] = 'hello world!'; |
@@ -5,10 +5,10 @@ |
||
5 | 5 | include "MyMiddleware.php"; // here your MyMiddleware class definition |
6 | 6 | $app = new \uSilex\Application; |
7 | 7 | $app['uSilex.request'] = \Zend\Diactoros\ServerRequestFactory::fromGlobals(); |
8 | -$app['uSilex.responseEmitter'] = $app->protect(function ($response) { |
|
8 | +$app['uSilex.responseEmitter'] = $app->protect(function($response) { |
|
9 | 9 | echo $response->getBody(); |
10 | 10 | }); |
11 | -$app['uSilex.httpHandler'] = function ($app) { |
|
11 | +$app['uSilex.httpHandler'] = function($app) { |
|
12 | 12 | return new \Relay\Relay([new MyMiddleware($app)]); |
13 | 13 | }; |
14 | 14 | $app->run(); |
@@ -3,14 +3,14 @@ |
||
3 | 3 | * Here your routes |
4 | 4 | */ |
5 | 5 | |
6 | -$routeMap->get('home', '/', function () { |
|
6 | +$routeMap->get('home', '/', function() { |
|
7 | 7 | return "This is the home. Try '/hello'"; |
8 | 8 | }); |
9 | 9 | |
10 | -$routeMap->get('hello', '/hello', function () { |
|
10 | +$routeMap->get('hello', '/hello', function() { |
|
11 | 11 | return "Hello. Try '/hello/world'"; |
12 | 12 | }); |
13 | 13 | |
14 | -$routeMap->get('hello_name', '/hello/{name}', function ($request) { |
|
14 | +$routeMap->get('hello_name', '/hello/{name}', function($request) { |
|
15 | 15 | return "Hello ".$request->getAttribute('name'); |
16 | 16 | }); |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | |
20 | 20 | // Error handler middleware configuration |
21 | 21 | // from: https://github.com/middlewares/error-handler |
22 | - $app['errorHandlingMiddleware'] = function () { |
|
22 | + $app['errorHandlingMiddleware'] = function() { |
|
23 | 23 | return (new ErrorHandler())->catchExceptions(true); |
24 | 24 | }; |
25 | 25 | |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | // aura routing middleware configuration |
28 | 28 | // from: https://github.com/middlewares/aura-router |
29 | 29 | $app['basepath'] = '/'; |
30 | - $app['auraRouterMiddleware'] = function ($app) { |
|
30 | + $app['auraRouterMiddleware'] = function($app) { |
|
31 | 31 | $routeContainer = new RouterContainer($app['basepath']); |
32 | 32 | $routeMap = $routeContainer->getMap(); |
33 | 33 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | |
40 | 40 | // register the RequestHandler |
41 | 41 | // from https://github.com/middlewares/request-handler |
42 | - $app['requestHandlerMiddleware'] = function () { |
|
42 | + $app['requestHandlerMiddleware'] = function() { |
|
43 | 43 | return new RequestHandler(); |
44 | 44 | }; |
45 | 45 | } |
@@ -18,8 +18,8 @@ discard block |
||
18 | 18 | public function register(Container $app) |
19 | 19 | { |
20 | 20 | // using middleware function |
21 | - $app['home_page'] = function ($app) { |
|
22 | - return middleware(function ($req, $handler) use ($app) { |
|
21 | + $app['home_page'] = function($app) { |
|
22 | + return middleware(function($req, $handler) use ($app) { |
|
23 | 23 | if (!in_array($req->getUri()->getPath(), [$app['basepath'].'/', $app['basepath']], true)) { |
24 | 24 | return $handler->handle($req); |
25 | 25 | } |
@@ -32,8 +32,8 @@ discard block |
||
32 | 32 | }; |
33 | 33 | |
34 | 34 | // using path function |
35 | - $app['hello_page'] = function ($app) { |
|
36 | - return path($app['basepath'].'/hi', middleware(function ($req, $handler) { |
|
35 | + $app['hello_page'] = function($app) { |
|
36 | + return path($app['basepath'].'/hi', middleware(function($req, $handler) { |
|
37 | 37 | $response = new Response(); |
38 | 38 | $response->getBody()->write("Hi. Try anything but/hi"); |
39 | 39 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | }; |
43 | 43 | |
44 | 44 | // using standard middleware as defaultt page |
45 | - $app['default_page'] = function ($app) { |
|
45 | + $app['default_page'] = function($app) { |
|
46 | 46 | return new MyMiddleware($app); |
47 | 47 | }; |
48 | 48 | } |