Pagination on the list, optional auth

This commit is contained in:
2024-07-22 16:19:01 +02:00
parent 7ee04b0a4b
commit 5251c43a6b
11 changed files with 499 additions and 119 deletions
+20
View File
@@ -0,0 +1,20 @@
<?php
namespace Api\Posts;
use Khofmann\Api\Api;
use Khofmann\Input\Input;
use Khofmann\Models\Post\Post;
use Khofmann\Request\Request;
use Khofmann\Response\Response;
class Posts extends Api
{
public function get()
{
$page = max(0, intval(Input::get("p", 0)));
$limit = constrain(0, 30, intval(Input::get("l", 10)));
$authed = Request::header("token") !== null;
Response::json(Post::list($page, $limit, $authed));
}
}