Removed server property from Router options.

This commit is contained in:
李铭昕 2019-07-05 11:03:27 +08:00
parent d863e8d68c
commit 6951d2d364
3 changed files with 23 additions and 1 deletions

View File

@ -14,6 +14,10 @@
- [#110](https://github.com/hyperf-cloud/hyperf/pull/110) [#111](https://github.com/hyperf-cloud/hyperf/pull/111) Fixed Redis::select is not work expected.
- [#131](https://github.com/hyperf-cloud/hyperf/pull/131) Fixed property middlewares not work in `Router::addGroup`.
# Removed
- [#131](https://github.com/hyperf-cloud/hyperf/pull/131) Removed `server` property from Router options.
# v1.0.3 - 2019-07-02
## Added

View File

@ -82,7 +82,7 @@ class DispatcherFactory
$parser = new Std();
$generator = new DataGenerator();
return $this->routers[$serverName] = new RouteCollector($parser, $generator);
return $this->routers[$serverName] = new RouteCollector($parser, $generator, $serverName);
}
protected function initAnnotationRoute(array $collector): void

View File

@ -81,4 +81,22 @@ class RouteCollectorTest extends TestCase
$this->assertSame(['PostMiddleware'], $middle['http']['/']['POST']);
$this->assertSame(['ApiGetMiddleware', 'ApiSelfGetMiddleware'], $middle['http']['/api/']['GET']);
}
public function testAddGroupMiddlewareFromAnotherServer()
{
$parser = new Std();
$generator = new DataGenerator();
$collector = new RouteCollector($parser, $generator, 'test');
$collector->addGroup('/api', function ($collector) {
$collector->get('/', 'Handler::ApiGet', [
'middleware' => ['ApiSelfGetMiddleware'],
]);
}, [
'middleware' => ['ApiGetMiddleware'],
]);
$middle = MiddlewareManager::$container;
$this->assertSame(['ApiGetMiddleware', 'ApiSelfGetMiddleware'], $middle['test']['/api/']['GET']);
}
}