diff --git a/src/flextype/Foundation/Flextype.php b/src/flextype/Foundation/Flextype.php index 095f8b42..93f155c6 100644 --- a/src/flextype/Foundation/Flextype.php +++ b/src/flextype/Foundation/Flextype.php @@ -12,6 +12,8 @@ namespace Flextype\Foundation; use Exception; use Psr\Container\ContainerInterface; use Slim\App; +use Slim\Http\Environment; +use Slim\Http\Uri; use function is_null; @@ -86,6 +88,16 @@ final class Flextype extends App return self::$instances[$cls]; } + /** + * Determine API Request + * + * @return bool + */ + public function isApiRequest(): bool + { + return explode('/', Uri::createFromEnvironment(new Environment($_SERVER))->getPath())[0] === 'api'; + } + /** * Returns the current Flextype version */