Fix POST argument parsing
This commit is contained in:
1 parent
4c4fffaf9d
commit
15e9d4c184
6 files changed
+38
-8
No files matched your search
@@ -44,7 +44,10 @@ $router->post("/endpoint", function (Request $req, Response $response) use ($gat
|
||||
$endpoint = new Endpoint(HttpClient::create(), $gateway);
|
||||
|
||||
try {
|
||||
$endpoint->receiveWebmention($source, $target);
|
||||
$id = $endpoint->receiveWebmention($source, $target);
|
||||
|
||||
$response->header('Location', "/webmention/" . $id);
|
||||
$response->status_code = StatusCode::Created;
|
||||
} catch (InvalidUrlException) {
|
||||
$response->status_code = StatusCode::BadRequest;
|
||||
return "Source and target must be valid URLs";
|
||||
@@ -59,10 +62,10 @@ $router->post("/endpoint", function (Request $req, Response $response) use ($gat
|
||||
return "Source does not mention the target";
|
||||
}
|
||||
|
||||
$response->status_code = StatusCode::Created;
|
||||
return;
|
||||
});
|
||||
|
||||
$router->get('/webmention/(\d+)', [$apiController, "get"]);
|
||||
|
||||
$router->get('/', fn($req, $res) => "<h1>Webmention server</h1>");
|
||||
|
||||
$router->get('/api/webmentions', [$apiController, "list"]);
|
||||
|
||||
Reference in new issue
Block a user