nextcloud/lib/private/OCM/OCMDiscoveryHandler.php
Maxence Lange e456f116b8 feat(ocm): handle /well-known/ocm
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
2025-11-07 08:55:16 -01:00

31 lines
788 B
PHP

<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OC\OCM;
use OCP\AppFramework\Http\JSONResponse;
use OCP\Http\WellKnown\GenericResponse;
use OCP\Http\WellKnown\IHandler;
use OCP\Http\WellKnown\IRequestContext;
use OCP\Http\WellKnown\IResponse;
class OCMDiscoveryHandler implements IHandler {
public function __construct(
private readonly OCMDiscoveryService $discoveryService,
) {
}
public function handle(string $service, IRequestContext $context, ?IResponse $previousResponse): ?IResponse {
if ($service !== 'ocm') {
return $previousResponse;
}
return new GenericResponse(new JsonResponse($this->discoveryService->getLocalOCMProvider()));
}
}