Skip to content

Commit 0dd5850

Browse files
committed
in constructor
1 parent 060f043 commit 0dd5850

1 file changed

Lines changed: 9 additions & 13 deletions

File tree

solid/lib/AppInfo/Application.php

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,15 @@ class Application extends App implements IBootstrap {
3131
*/
3232
public function __construct(array $urlParams = []) {
3333
parent::__construct(self::APP_ID, $urlParams);
34-
}
34+
$container->registerService(SolidCorsMiddleware::class, function(IServerContainer $c): SolidCorsMiddleware{
35+
return new SolidCorsMiddleware(
36+
$c->get(IRequest::class)
37+
);
38+
});
39+
40+
// executed in the order that it is registered
41+
$container->registerMiddleware(SolidCorsMiddleware::class);
42+
}
3543

3644
public function register(IRegistrationContext $context): void {
3745
$context->registerWellKnownHandler(\OCA\Solid\WellKnown\OpenIdConfigurationHandler::class);
@@ -54,18 +62,6 @@ public function register(IRegistrationContext $context): void {
5462
$context->registerService('User', function($c) {
5563
return $c->query('UserSession')->getUser();
5664
});
57-
58-
/**
59-
* Middleware
60-
*/
61-
$context->registerService('SolidCorsMiddleware', function($c) {
62-
return new SolidCorsMiddleware(
63-
$c->get(IRequest::class)
64-
);
65-
});
66-
67-
// executed in the order that it is registered
68-
$context->registerMiddleware('SolidCorsMiddleware');
6965
}
7066

7167
public function boot(IBootContext $context): void {

0 commit comments

Comments
 (0)