mirror of
https://github.com/wallabag/wallabag.git
synced 2025-09-15 18:57:05 +00:00
api/entries: add parameter detail to exclude or include content in response
detail=metadata will nullify the content field of entries in order to make smaller responses. detail=full keeps the former behavior, it sends the content of entries. It's the default, for backward compatibility. Fixes #2817 Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
This commit is contained in:
parent
de1162b91a
commit
2c290747cb
3 changed files with 42 additions and 2 deletions
|
@ -103,6 +103,7 @@ class EntryRestController extends WallabagRestController
|
|||
* {"name"="tags", "dataType"="string", "required"=false, "format"="api,rest", "description"="a list of tags url encoded. Will returns entries that matches ALL tags."},
|
||||
* {"name"="since", "dataType"="integer", "required"=false, "format"="default '0'", "description"="The timestamp since when you want entries updated."},
|
||||
* {"name"="public", "dataType"="integer", "required"=false, "format"="1 or 0, all entries by default", "description"="filter by entries with a public link"},
|
||||
* {"name"="detail", "dataType"="string", "required"=false, "format"="metadata or full, metadata by default", "description"="include content field if 'full'. 'full' by default for backward compatibility."},
|
||||
* }
|
||||
* )
|
||||
*
|
||||
|
@ -121,6 +122,7 @@ class EntryRestController extends WallabagRestController
|
|||
$perPage = (int) $request->query->get('perPage', 30);
|
||||
$tags = \is_array($request->query->get('tags')) ? '' : (string) $request->query->get('tags', '');
|
||||
$since = $request->query->get('since', 0);
|
||||
$detail = strtolower($request->query->get('detail', 'full'));
|
||||
|
||||
try {
|
||||
/** @var \Pagerfanta\Pagerfanta $pager */
|
||||
|
@ -132,7 +134,8 @@ class EntryRestController extends WallabagRestController
|
|||
$sort,
|
||||
$order,
|
||||
$since,
|
||||
$tags
|
||||
$tags,
|
||||
$detail
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
throw new BadRequestHttpException($e->getMessage());
|
||||
|
@ -156,6 +159,7 @@ class EntryRestController extends WallabagRestController
|
|||
'perPage' => $perPage,
|
||||
'tags' => $tags,
|
||||
'since' => $since,
|
||||
'detail' => $detail,
|
||||
],
|
||||
true
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue