diff options
author | provokateurin <kate@provokateurin.de> | 2025-05-19 09:07:08 +0200 |
---|---|---|
committer | provokateurin <kate@provokateurin.de> | 2025-05-20 13:10:34 +0200 |
commit | ad031188bca7578ce1ad706554be077a90af18a0 (patch) | |
tree | 5ef4c262c658d51a12a9b67a238771be0d7966c0 /lib/public/AppFramework | |
parent | 249e33fcd67034b63aafdc7c3debd84982eb3cb3 (diff) | |
download | nextcloud-server-feat/http/request-header-attribute.tar.gz nextcloud-server-feat/http/request-header-attribute.zip |
feat(Http): Add RequestHeader attributefeat/http/request-header-attribute
Signed-off-by: provokateurin <kate@provokateurin.de>
Diffstat (limited to 'lib/public/AppFramework')
-rw-r--r-- | lib/public/AppFramework/Http/Attribute/RequestHeader.php | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/public/AppFramework/Http/Attribute/RequestHeader.php b/lib/public/AppFramework/Http/Attribute/RequestHeader.php new file mode 100644 index 00000000000..c9327eec4c0 --- /dev/null +++ b/lib/public/AppFramework/Http/Attribute/RequestHeader.php @@ -0,0 +1,50 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +namespace OCP\AppFramework\Http\Attribute; + +use Attribute; + +/** + * This attribute allows documenting request headers and is primarily intended for OpenAPI documentation. + * It should be added whenever you use a request header in a controller method, in order to properly describe the header and its functionality. + * There are no checks that ensure the header is set, so you will still need to do this yourself in the controller method. + * + * @since 32.0.0 + */ +#[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)] +class RequestHeader { + /** + * @param string $name The name of the request header + * @param string $description The description of the request header + */ + public function __construct( + protected string $name, + protected string $description, + ) { + } + + /** + * @return string The name of the request header. + * + * @since 32.0.0 + */ + public function getName(): string { + return $this->name; + } + + /** + * @return string The description of the request header. + * + * @since 32.0.0 + */ + public function getDescription(): string { + return $this->description; + } +} |