From 4d26000a26da2edbd1403da993bdcf215434171c Mon Sep 17 00:00:00 2001 From: Aldarien Date: Thu, 2 Jul 2020 01:06:39 -0400 Subject: [PATCH] Controller traits --- common/Define/Controller/Json.php | 20 ++++++++++++++++++++ common/Define/Controller/Redirect.php | 12 ++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 common/Define/Controller/Json.php create mode 100644 common/Define/Controller/Redirect.php diff --git a/common/Define/Controller/Json.php b/common/Define/Controller/Json.php new file mode 100644 index 0000000..76dd338 --- /dev/null +++ b/common/Define/Controller/Json.php @@ -0,0 +1,20 @@ +getBody()->write($data); + return $request + ->withHeader('Content-Type', 'application/json') + ->withStatus(201); + } +} diff --git a/common/Define/Controller/Redirect.php b/common/Define/Controller/Redirect.php new file mode 100644 index 0000000..5b796be --- /dev/null +++ b/common/Define/Controller/Redirect.php @@ -0,0 +1,12 @@ +withHeader('Location', $uri) + ->withStatus($status); + } +}