X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FCapabilities%2FICanCreateResponses.php;h=dbdc61d843a64b0bca16a2384618fb76a9c0ea24;hb=b0898ada2942e4207b0fb6dfacb8ffbdd3c6945e;hp=282458136bb58aae726a4fd71e5f4ebf94631d7b;hpb=537b74f3079a046750bc210bbd9e51c1187b361d;p=friendica.git diff --git a/src/Capabilities/ICanCreateResponses.php b/src/Capabilities/ICanCreateResponses.php index 282458136b..dbdc61d843 100644 --- a/src/Capabilities/ICanCreateResponses.php +++ b/src/Capabilities/ICanCreateResponses.php @@ -1,11 +1,52 @@ . + * + */ namespace Friendica\Capabilities; use Friendica\Network\HTTPException\InternalServerErrorException; +use Psr\Http\Message\ResponseInterface; -interface ICanCreateResponses extends IRespondToRequests +interface ICanCreateResponses { + /** + * This constant helps to find the specific return type of responses inside the headers array + */ + const X_HEADER = 'X-RESPONSE-TYPE'; + + const TYPE_HTML = 'html'; + const TYPE_XML = 'xml'; + const TYPE_JSON = 'json'; + const TYPE_ATOM = 'atom'; + const TYPE_RSS = 'rss'; + const TYPE_BLANK = 'blank'; + + const ALLOWED_TYPES = [ + self::TYPE_HTML, + self::TYPE_XML, + self::TYPE_JSON, + self::TYPE_ATOM, + self::TYPE_RSS, + self::TYPE_BLANK, + ]; + /** * Adds a header entry to the module response * @@ -30,4 +71,22 @@ interface ICanCreateResponses extends IRespondToRequests * @throws InternalServerErrorException */ public function setType(string $type, ?string $content_type = null): void; + + /** + * Sets the status and the reason for the response + * + * @param int $status The HTTP status code + * @param null|string $reason Reason phrase (when empty a default will be used based on the status code) + * + * @return void + */ + public function setStatus(int $status = 200, ?string $reason = null): void; + + /** + * Creates a PSR-7 compliant interface + * @see https://www.php-fig.org/psr/psr-7/ + * + * @return ResponseInterface + */ + public function generate(): ResponseInterface; }