Skip to content

Commit f43182e

Browse files
committed
优化route
1 parent e5bbe38 commit f43182e

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"require": {
66
"react/event-loop": "^1.0",
77
"react/async": "^4.3",
8-
"reactphp-x/framework-x": "^0.16.1"
8+
"clue/framework-x": "^0.16",
9+
"reactphp-x/route": "^1.0"
910
},
1011
"license": "MIT",
1112
"authors": [

src/Facades/Route.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ class Route extends Facade
2323
{
2424
protected static function getFacadeAccessor()
2525
{
26-
return 'reactphp.server';
26+
return 'reactphp.route';
2727
}
2828
}

src/Providers/ServerServiceProvider.php

+8-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public function register()
1818
{
1919
$this->mergeConfigs();
2020
$this->registerLoop();
21+
$this->registerRoute();
2122
$this->registerServer();
2223
$this->registerManager();
2324
$this->registerCommands();
@@ -50,10 +51,16 @@ protected function registerLoop()
5051
$this->app->alias('React\EventLoop\LoopInterface', 'reactphp.loop');
5152
}
5253

54+
protected function registerRoute()
55+
{
56+
$this->app->singleton('reactphp.route', function ($app) {
57+
return new \ReactphpX\Route\Route($app);
58+
});
59+
}
5360
protected function registerServer()
5461
{
5562
$this->app->singleton('reactphp.server', function ($app) {
56-
return new App(new \FrameworkX\Container($app), ...(array_filter($app['config']->get('reactphp.middlewares', []))));
63+
return new App(...(array_filter($app['config']->get('reactphp.middlewares', []))), $app->get('reactphp.route'));
5764
});
5865
}
5966

0 commit comments

Comments
 (0)