2024-02-22 10:05:09 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once "lib/newsarticle.php";
|
|
|
|
|
|
|
|
function endpoint($endpoint_data): array
|
|
|
|
{
|
|
|
|
|
|
|
|
return match ($endpoint_data["action"]) {
|
|
|
|
"getNewsArticles" => getNewsArticles(),
|
|
|
|
"addNewsArticle" => addNewsArticle(
|
|
|
|
$endpoint_data["title"],
|
|
|
|
$endpoint_data["body"]
|
|
|
|
),
|
2024-04-28 22:37:23 +02:00
|
|
|
"addNewsComment" => addNewsComment(
|
|
|
|
$endpoint_data["user_id"],
|
|
|
|
$endpoint_data['news_article_id'],
|
|
|
|
$endpoint_data["comment_text"],
|
|
|
|
$endpoint_data["parent_id"]
|
|
|
|
),
|
2024-02-22 10:05:09 +01:00
|
|
|
default => ["Status" => "Fail", "message" => "Invalid action"],
|
|
|
|
};
|
|
|
|
}
|