Add support for `DELETE` requests
authorAlexander Ebert <ebert@woltlab.com>
Mon, 11 Mar 2024 15:31:22 +0000 (16:31 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 11 Mar 2024 15:31:22 +0000 (16:31 +0100)
wcfsetup/install/files/lib/action/ApiAction.class.php
wcfsetup/install/files/lib/system/endpoint/DeleteRequest.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/endpoint/RequestMethod.class.php

index baf138b58dd62f95b3b4f4cd354aaaba2f1ce52a..6721ade812238fd24feb66fc6e437becf04b9089 100644 (file)
@@ -10,6 +10,7 @@ use Laminas\Diactoros\Response\JsonResponse;
 use Psr\Http\Message\ServerRequestInterface;
 use Psr\Http\Message\ResponseInterface;
 use Psr\Http\Server\RequestHandlerInterface;
+use wcf\http\attribute\AllowHttpMethod;
 use wcf\system\endpoint\event\ControllerCollecting;
 use wcf\system\endpoint\IController;
 use wcf\system\endpoint\RequestFailure;
@@ -21,6 +22,7 @@ use wcf\system\request\RouteHandler;
 
 use function FastRoute\simpleDispatcher;
 
+#[AllowHttpMethod('DELETE')]
 final class ApiAction implements RequestHandlerInterface
 {
     #[\Override]
diff --git a/wcfsetup/install/files/lib/system/endpoint/DeleteRequest.class.php b/wcfsetup/install/files/lib/system/endpoint/DeleteRequest.class.php
new file mode 100644 (file)
index 0000000..6b43821
--- /dev/null
@@ -0,0 +1,12 @@
+<?php
+
+namespace wcf\system\endpoint;
+
+#[\Attribute(\Attribute::TARGET_CLASS)]
+final class DeleteRequest extends RequestType
+{
+    public function __construct(string $uri)
+    {
+        parent::__construct(RequestMethod::GET, $uri);
+    }
+}
index 333931bb3c6c74afd8b84a213edc4231238bde4b..3ce4142fe44375ec5f8483de6195707610a8ef9f 100644 (file)
@@ -4,12 +4,14 @@ namespace wcf\system\endpoint;
 
 enum RequestMethod
 {
+    case DELETE;
     case GET;
     case POST;
 
     public function toString(): string
     {
         return match ($this) {
+            self::DELETE => 'DELETE',
             self::GET => 'GET',
             self::POST => 'POST',
         };