diff --git a/src/middleware/ApiKeyHandler.php b/src/middleware/ApiKeyHandler.php new file mode 100644 index 0000000000000000000000000000000000000000..7a683bdf991c4693275083674ac9891d679d7bcd --- /dev/null +++ b/src/middleware/ApiKeyHandler.php @@ -0,0 +1,35 @@ +<?php + +class ApiKeyHandler +{ + private static $instance; + private $apiKey; + + private function __construct() + { + $this->apiKey = $_ENV['API_KEY']; + } + /** + * @return ApiKeyHandler + */ + public static function getInstance() + { + if (!isset(self::$instance)) { + self::$instance = new static(); + } + return self::$instance; + } + + public function checkApiKey($apiKeyHeader) + { + $res = $this->apiKey === $apiKeyHeader; + // if (!$res) { + // throw new Exception('Invalid API Key'); + // } + return $res; + } + +} + + +?> \ No newline at end of file