Skip to content

Commit 2aa78af

Browse files
committed
add routes
1 parent 92b9898 commit 2aa78af

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
namespace Pdsinterop\PhpSolid\Routes;
3+
4+
use Pdsinterop\PhpSolid\StorageServer;
5+
6+
class SolidStorageProvider {
7+
public static function respondToStorageNew() {
8+
try {
9+
$webId = StorageServer::getWebId($rawRequest);
10+
11+
if (!isset($webId)) {
12+
$response = $resourceServer->getResponse()
13+
->withStatus(409, "Invalid token");
14+
StorageServer::respond($response);
15+
exit();
16+
}
17+
} catch (\Throwable $e) {
18+
$webId = $_POST['webId'];
19+
// FIXME: Check against a trusted remote party;
20+
}
21+
22+
if (!isset($webId)) {
23+
header("HTTP/1.1 400 Bad Request");
24+
exit();
25+
}
26+
27+
$createdStorage = StorageServer::createStorage($webId);
28+
if (!$createdStorage) {
29+
error_log("Failed to create storage");
30+
header("HTTP/1.1 400 Bad Request");
31+
exit();
32+
}
33+
34+
//Mailer::sendStorageCreated($createdStoage);
35+
36+
$responseData = array(
37+
"storageId" => $createdStorage['storageId']
38+
);
39+
header("HTTP/1.1 201 Created");
40+
header("Content-type: application/json");
41+
echo json_encode($responseData, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR);
42+
}
43+
}
44+

0 commit comments

Comments
 (0)