Skip to content

Commit 742f44d

Browse files
committed
Merge branch 'master' of github.com:mevdschee/php-crud-api
2 parents a70fb5b + 8933141 commit 742f44d

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/Tqdev/PhpCrudApi/Middleware/Router/SimpleRouter.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ private function detectBasePath(string $basePath): string
5050
return substr($fullPath, 0, -1 * strlen($path));
5151
}
5252
}
53-
return $fullPath;
53+
if ('/' . basename(__FILE__) == $fullPath) {
54+
return $fullPath;
55+
}
5456
}
5557
return '/';
5658
}

src/Tqdev/PhpCrudApi/ResponseFactory.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
class ResponseFactory
99
{
1010
const OK = 200;
11+
const MOVED_PERMANENTLY = 301;
12+
const FOUND = 302;
1113
const UNAUTHORIZED = 401;
1214
const FORBIDDEN = 403;
1315
const NOT_FOUND = 404;
@@ -23,8 +25,7 @@ public static function fromXml(int $status, string $xml): ResponseInterface
2325

2426
public static function fromCsv(int $status, string $csv): ResponseInterface
2527
{
26-
$response = self::from($status, 'text/csv', $csv);
27-
return $response->withHeader('Content-Type', 'text/csv');
28+
return self::from($status, 'text/csv', $csv);
2829
}
2930

3031
public static function fromHtml(int $status, string $html): ResponseInterface
@@ -38,7 +39,7 @@ public static function fromObject(int $status, $body): ResponseInterface
3839
return self::from($status, 'application/json', $content);
3940
}
4041

41-
private static function from(int $status, string $contentType, string $content): ResponseInterface
42+
public static function from(int $status, string $contentType, string $content): ResponseInterface
4243
{
4344
$psr17Factory = new Psr17Factory();
4445
$response = $psr17Factory->createResponse($status);

0 commit comments

Comments
 (0)