Browse Source

Serve index.html when requested path is a directory.

master
Gerben 1 year ago
parent
commit
0e37e3acdb
1 changed files with 6 additions and 2 deletions
  1. +6
    -2
      lib/Controller/RawResponse.php

+ 6
- 2
lib/Controller/RawResponse.php View File

@@ -6,8 +6,12 @@ use \Exception;
trait RawResponse {
protected function returnRawResponse($fileNode) {
if ($fileNode->getType() === 'dir') {
// Is there some reasonable thing to return for a directory? An html index? A tarball?
throw new Exception("Requested share is a directory, not a file.");
// If the requested path is a folder, try return its index.html.
try {
$fileNode = $fileNode->get('index.html');
} catch (NotFoundException $e) {
return new NotFoundResponse();
}
}

$content = $fileNode->getContent();


Loading…
Cancel
Save