1
0
Fork 0
mirror of synced 2024-09-20 03:17:30 +12:00

Add pagination to templates

This commit is contained in:
Khushboo Verma 2024-07-29 16:02:49 +05:30
parent af94fc7882
commit 7dca530f70

View file

@ -2368,9 +2368,11 @@ App::get('/v1/functions/templates')
->label('sdk.response.code', Response::STATUS_CODE_OK)
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_TEMPLATE_FUNCTION_LIST)
->param('limit', 10, new Range(0, 200), 'Limit the number of templates returned in the response. Max limit: 100.', true)
->param('offset', 0, new Range(0, 200), 'Offset the list of returned templates. Max offset: 100.', true)
->inject('response')
->action(function (Response $response) {
$templates = Config::getParam('function-templates', []);
->action(function (int $limit, int $offset, Response $response) {
$templates = \array_slice(Config::getParam('function-templates', []), $offset, $limit);
$response->dynamic(new Document([
'templates' => $templates,
'total' => \count($templates),