-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: jld3103 <[email protected]>
- Loading branch information
1 parent
8b1d849
commit c5d818d
Showing
6 changed files
with
39 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
* | ||
* @author Morris Jobke <[email protected]> | ||
* @author Roeland Jago Douma <[email protected]> | ||
* @author Kate Döen <[email protected]> | ||
* | ||
* @license GNU AGPL version 3 or any later version | ||
* | ||
|
@@ -46,6 +47,9 @@ public function __construct(IRequest $request) { | |
$this->useGZip = false; | ||
} | ||
|
||
/** | ||
* @param Response<int, array<string, mixed>> $response | ||
*/ | ||
public function afterController($controller, $methodName, Response $response) { | ||
// By default we do not gzip | ||
$allowGzip = false; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
* @author Joas Schilling <[email protected]> | ||
* @author Lukas Reschke <[email protected]> | ||
* @author Roeland Jago Douma <[email protected]> | ||
* @author Kate Döen <[email protected]> | ||
* | ||
* @license GNU AGPL version 3 or any later version | ||
* | ||
|
@@ -90,7 +91,7 @@ public function afterException($controller, $methodName, \Exception $exception) | |
/** | ||
* @param Controller $controller | ||
* @param string $methodName | ||
* @param Response $response | ||
* @param Response|JSONResponse $response | ||
* @return \OCP\AppFramework\Http\Response | ||
*/ | ||
public function afterController($controller, $methodName, Response $response) { | ||
|
@@ -102,7 +103,7 @@ public function afterController($controller, $methodName, Response $response) { | |
if ($response->getStatus() === Http::STATUS_UNAUTHORIZED) { | ||
$message = ''; | ||
if ($response instanceof JSONResponse) { | ||
/** @var DataResponse $response */ | ||
/** @var DataResponse<Http::STATUS_UNAUTHORIZED, array, array{}> $response */ | ||
$message = $response->getData()['message']; | ||
} | ||
|
||
|
@@ -111,7 +112,7 @@ public function afterController($controller, $methodName, Response $response) { | |
if ($response->getStatus() === Http::STATUS_FORBIDDEN) { | ||
$message = ''; | ||
if ($response instanceof JSONResponse) { | ||
/** @var DataResponse $response */ | ||
/** @var DataResponse<Http::STATUS_FORBIDDEN, array, array{}> $response */ | ||
$message = $response->getData()['message']; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
* @author Joas Schilling <[email protected]> | ||
* @author Lukas Reschke <[email protected]> | ||
* @author Roeland Jago Douma <[email protected]> | ||
* @author Kate Döen <[email protected]> | ||
* | ||
* @license GNU AGPL version 3 or any later version | ||
* | ||
|
@@ -30,6 +31,13 @@ | |
use OCP\AppFramework\Http\DataResponse; | ||
use OCP\AppFramework\Http\Response; | ||
|
||
/** | ||
* @psalm-import-type DataResponseType from DataResponse | ||
* @template S of int | ||
* @template-covariant T of DataResponseType | ||
* @template H of array<string, mixed> | ||
* @template-extends Response<S, H> | ||
*/ | ||
abstract class BaseResponse extends Response { | ||
/** @var array */ | ||
protected $data; | ||
|
@@ -49,7 +57,7 @@ abstract class BaseResponse extends Response { | |
/** | ||
* BaseResponse constructor. | ||
* | ||
* @param DataResponse $dataResponse | ||
* @param DataResponse<S, T, H> $dataResponse | ||
* @param string $format | ||
* @param string|null $statusMessage | ||
* @param int|null $itemsCount | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
* @author Christoph Wurst <[email protected]> | ||
* @author Joas Schilling <[email protected]> | ||
* @author Roeland Jago Douma <[email protected]> | ||
* @author Kate Döen <[email protected]> | ||
* | ||
* @license GNU AGPL version 3 or any later version | ||
* | ||
|
@@ -25,13 +26,22 @@ | |
namespace OC\AppFramework\OCS; | ||
|
||
use OCP\AppFramework\Http; | ||
use OCP\AppFramework\Http\DataResponse; | ||
use OCP\AppFramework\OCSController; | ||
|
||
/** | ||
* @psalm-import-type DataResponseType from DataResponse | ||
* @template S of int | ||
* @template-covariant T of DataResponseType | ||
* @template H of array<string, mixed> | ||
* @template-extends BaseResponse<S, DataResponseType, H> | ||
*/ | ||
class V1Response extends BaseResponse { | ||
/** | ||
* The V1 endpoint has very limited http status codes basically everything | ||
* is status 200 except 401 | ||
* | ||
* @psalm-suppress ImplementedReturnTypeMismatch Expected because we match some status codes | ||
* @return int | ||
*/ | ||
public function getStatus() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
* | ||
* @author Christoph Wurst <[email protected]> | ||
* @author Roeland Jago Douma <[email protected]> | ||
* @author Kate Döen <[email protected]> | ||
* | ||
* @license GNU AGPL version 3 or any later version | ||
* | ||
|
@@ -24,13 +25,22 @@ | |
namespace OC\AppFramework\OCS; | ||
|
||
use OCP\AppFramework\Http; | ||
use OCP\AppFramework\Http\DataResponse; | ||
use OCP\AppFramework\OCSController; | ||
|
||
/** | ||
* @psalm-import-type DataResponseType from DataResponse | ||
* @template S of int | ||
* @template-covariant T of DataResponseType | ||
* @template H of array<string, mixed> | ||
* @template-extends BaseResponse<S, DataResponseType, H> | ||
*/ | ||
class V2Response extends BaseResponse { | ||
/** | ||
* The V2 endpoint just passes on status codes. | ||
* Of course we have to map the OCS specific codes to proper HTTP status codes | ||
* | ||
* @psalm-suppress ImplementedReturnTypeMismatch Expected because we match some status codes | ||
* @return int | ||
*/ | ||
public function getStatus() { | ||
|