aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/ApiBundle
diff options
context:
space:
mode:
authorKevin Decherf <kevin@kdecherf.com>2019-05-12 00:00:00 +0200
committerKevin Decherf <kevin@kdecherf.com>2019-05-18 18:11:08 +0200
commit2c290747cb0d235392f6e5d22205a706c6474168 (patch)
treefdf67f203aca096e8b61bd245b387d05cc38e20b /src/Wallabag/ApiBundle
parentde1162b91a205a98a3f8ed01bd80285793b18380 (diff)
downloadwallabag-2c290747cb0d235392f6e5d22205a706c6474168.tar.gz
wallabag-2c290747cb0d235392f6e5d22205a706c6474168.tar.zst
wallabag-2c290747cb0d235392f6e5d22205a706c6474168.zip
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>
Diffstat (limited to 'src/Wallabag/ApiBundle')
-rw-r--r--src/Wallabag/ApiBundle/Controller/EntryRestController.php6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/Wallabag/ApiBundle/Controller/EntryRestController.php b/src/Wallabag/ApiBundle/Controller/EntryRestController.php
index 06520af9..aff0534a 100644
--- a/src/Wallabag/ApiBundle/Controller/EntryRestController.php
+++ b/src/Wallabag/ApiBundle/Controller/EntryRestController.php
@@ -103,6 +103,7 @@ class EntryRestController extends WallabagRestController
103 * {"name"="tags", "dataType"="string", "required"=false, "format"="api,rest", "description"="a list of tags url encoded. Will returns entries that matches ALL tags."}, 103 * {"name"="tags", "dataType"="string", "required"=false, "format"="api,rest", "description"="a list of tags url encoded. Will returns entries that matches ALL tags."},
104 * {"name"="since", "dataType"="integer", "required"=false, "format"="default '0'", "description"="The timestamp since when you want entries updated."}, 104 * {"name"="since", "dataType"="integer", "required"=false, "format"="default '0'", "description"="The timestamp since when you want entries updated."},
105 * {"name"="public", "dataType"="integer", "required"=false, "format"="1 or 0, all entries by default", "description"="filter by entries with a public link"}, 105 * {"name"="public", "dataType"="integer", "required"=false, "format"="1 or 0, all entries by default", "description"="filter by entries with a public link"},
106 * {"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."},
106 * } 107 * }
107 * ) 108 * )
108 * 109 *
@@ -121,6 +122,7 @@ class EntryRestController extends WallabagRestController
121 $perPage = (int) $request->query->get('perPage', 30); 122 $perPage = (int) $request->query->get('perPage', 30);
122 $tags = \is_array($request->query->get('tags')) ? '' : (string) $request->query->get('tags', ''); 123 $tags = \is_array($request->query->get('tags')) ? '' : (string) $request->query->get('tags', '');
123 $since = $request->query->get('since', 0); 124 $since = $request->query->get('since', 0);
125 $detail = strtolower($request->query->get('detail', 'full'));
124 126
125 try { 127 try {
126 /** @var \Pagerfanta\Pagerfanta $pager */ 128 /** @var \Pagerfanta\Pagerfanta $pager */
@@ -132,7 +134,8 @@ class EntryRestController extends WallabagRestController
132 $sort, 134 $sort,
133 $order, 135 $order,
134 $since, 136 $since,
135 $tags 137 $tags,
138 $detail
136 ); 139 );
137 } catch (\Exception $e) { 140 } catch (\Exception $e) {
138 throw new BadRequestHttpException($e->getMessage()); 141 throw new BadRequestHttpException($e->getMessage());
@@ -156,6 +159,7 @@ class EntryRestController extends WallabagRestController
156 'perPage' => $perPage, 159 'perPage' => $perPage,
157 'tags' => $tags, 160 'tags' => $tags,
158 'since' => $since, 161 'since' => $since,
162 'detail' => $detail,
159 ], 163 ],
160 true 164 true
161 ) 165 )