forked from Adleraci/adlerka.top
Bruno Rybársky
1c9f5cf3c0
add additional clarification to some functions, add addNewsComment function and API, currently untested and not implemented in the client, fix a bunch of stuff that PHPStorm pointed out
22 lines
614 B
PHP
22 lines
614 B
PHP
<?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"]
|
|
),
|
|
"addNewsComment" => addNewsComment(
|
|
$endpoint_data["user_id"],
|
|
$endpoint_data['news_article_id'],
|
|
$endpoint_data["comment_text"],
|
|
$endpoint_data["parent_id"]
|
|
),
|
|
default => ["Status" => "Fail", "message" => "Invalid action"],
|
|
};
|
|
} |