diff --git a/app/Controllers/FileInfoController.php b/app/Controllers/FileInfoController.php new file mode 100644 index 0000000..1ecd785 --- /dev/null +++ b/app/Controllers/FileInfoController.php @@ -0,0 +1,35 @@ +getBody()->write(json_encode([ + 'hashes' => [ + 'md5' => hash('md5', file_get_contents($file->getPathname())), + 'sha1' => hash('sha1', file_get_contents($file->getPathname())), + 'sha256' => hash('sha256', file_get_contents($file->getPathname())), + ] + ])); + + return $response->withHeader('Content-Type', 'application/json'); + } +} diff --git a/index.php b/index.php index 8fb0728..9cd22a9 100644 --- a/index.php +++ b/index.php @@ -27,6 +27,7 @@ $container->call(Bootstrap\ViewComposer::class); $app = Bridge::create($container); // Register routes +$app->get('/file-info/[{path:.*}]', Controllers\FileInfoController::class); $app->get('/[{path:.*}]', Controllers\DirectoryController::class); // Enagage!