Skip to content

Commit b2d59b5

Browse files
Draft handler for /.well-known/solid
1 parent c1ed57f commit b2d59b5

2 files changed

Lines changed: 49 additions & 0 deletions

File tree

solid/lib/AppInfo/Application.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
use OCA\Solid\Service\UserService;
1313
use OCA\Solid\WellKnown\OpenIdConfigurationHandler;
14+
use OCA\Solid\WellKnown\SolidHandler;
1415
use OCA\Solid\Middleware\SolidCorsMiddleware;
1516

1617
use OCP\AppFramework\App;
@@ -58,6 +59,7 @@ public function __construct(array $urlParams = []) {
5859

5960
public function register(IRegistrationContext $context): void {
6061
$context->registerWellKnownHandler(\OCA\Solid\WellKnown\OpenIdConfigurationHandler::class);
62+
$context->registerWellKnownHandler(\OCA\Solid\WellKnown\SolidHandler::class);
6163

6264
/**
6365
* Core class wrappers
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
namespace OCA\Solid\WellKnown;
3+
4+
use OCP\IRequest;
5+
use OCP\IUserManager;
6+
use OCP\IURLGenerator;
7+
use OCP\IConfig;
8+
9+
use OCP\AppFramework\Http\JSONResponse;
10+
use OCP\Http\WellKnown\IHandler;
11+
use OCP\Http\WellKnown\IRequestContext;
12+
use OCP\Http\WellKnown\IResponse;
13+
14+
class SolidHandler implements IHandler {
15+
/* @var IURLGenerator */
16+
private $urlGenerator;
17+
18+
public function __construct(IRequest $request, IURLGenerator $urlGenerator, IConfig $config, IUserManager $userManager)
19+
{
20+
require_once(__DIR__.'/../../vendor/autoload.php');
21+
$this->urlGenerator = $urlGenerator;
22+
}
23+
24+
public function handle(string $service, IRequestContext $context, ?IResponse $previousResponse): ?IResponse {
25+
if ($service !== 'solid') {
26+
return $previousResponse;
27+
}
28+
29+
$body = [
30+
"@context" => [
31+
"https://www.w3.org/ns/solid/notification/v1"
32+
],
33+
"notificationChannel" => [
34+
[
35+
"id" => "websocketNotification",
36+
"type" => ["WebSocketSubscription2021"],
37+
"subscription" => "https://websocket.example/subscription",
38+
"feature" => ["state", "rate", "expiration"]
39+
]
40+
]
41+
];
42+
$result = new JSONResponse($body);
43+
$result->addHeader("Access-Control-Allow-Origin", "*");
44+
$result->setStatus(200);
45+
return $result;
46+
}
47+
}

0 commit comments

Comments
 (0)