post("/send", function(Request $req, Response $response) use ($webmention) { $source = $req->query["source"]; $webmention->sendForPage($source); }); $router->post("/endpoint", function(Request $req, Response $response) { $source = $req->post['source']; $target = $req->post['target']; $endpoint = new Endpoint(); try { $endpoint->receiveWebmention($source, $target); } catch (InvalidUrlException $e) { $response->status_code = StatusCode::BadRequest; return "Source and target must be valid URLs"; } catch (InvalidTargetException $e) { $response->status_code = StatusCode::BadRequest; return "Target must be on the domain lewisdale.dev"; } $response->status_code = StatusCode::Created; }); $router->dispatch(); ?>