Skip to content

Commit

Permalink
add support to create directories with POST
Browse files Browse the repository at this point in the history
  • Loading branch information
ylebre committed Jan 17, 2024
1 parent 330123a commit 9d02fe0
Showing 1 changed file with 26 additions and 18 deletions.
44 changes: 26 additions & 18 deletions src/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,27 +210,35 @@ private function handle(string $method, string $path, $contents, $request): Resp
} else {
$filename = $this->guid();
}
// FIXME: make this list complete for at least the things we'd expect (turtle, n3, jsonld, ntriples, rdf);
switch ($contentType) {
case '':
// FIXME: if no content type was passed, we should reject the request according to the spec;
break;
case "text/plain":
$filename .= ".txt";
break;
case "text/turtle":
$filename .= ".ttl";
break;
case "text/html":
$filename .= ".html";

$link = $request->getHeaderLine("Link");
switch ($link) {
case '<http://www.w3.org/ns/ldp#BasicContainer>; rel="type"':
$response = $this->handleCreateDirectoryRequest($response, $path . $filename);
break;
case "application/json":
case "application/ld+json":
$filename .= ".json";
default:
// FIXME: make this list complete for at least the things we'd expect (turtle, n3, jsonld, ntriples, rdf);
switch ($contentType) {
case '':
// FIXME: if no content type was passed, we should reject the request according to the spec;
break;
case "text/plain":
$filename .= ".txt";
break;
case "text/turtle":
$filename .= ".ttl";
break;
case "text/html":
$filename .= ".html";
break;
case "application/json":
case "application/ld+json":
$filename .= ".json";
break;
}
$response = $this->handleCreateRequest($response, $path . $filename, $contents);
break;
}

$response = $this->handleCreateRequest($response, $path . $filename, $contents);
} else {
$response = $this->handleUpdateRequest($response, $path, $contents);
}
Expand Down

0 comments on commit 9d02fe0

Please sign in to comment.