|
9 | 9 | ) |
10 | 10 | from models_library.api_schemas_webserver.users import MyFunctionPermissionsGet |
11 | 11 | from models_library.functions import FunctionClass, RegisteredProjectFunction |
12 | | -from models_library.rest_pagination import Page |
| 12 | +from models_library.rest_pagination import ItemT, Page |
13 | 13 | from models_library.rest_pagination_utils import paginate_data |
14 | 14 | from pydantic import TypeAdapter |
15 | 15 | from servicelib.aiohttp import status |
|
18 | 18 | parse_request_path_parameters_as, |
19 | 19 | parse_request_query_parameters_as, |
20 | 20 | ) |
| 21 | +from servicelib.mimetype_constants import MIMETYPE_APPLICATION_JSON |
| 22 | +from servicelib.rest_constants import RESPONSE_MODEL_POLICY |
21 | 23 |
|
22 | 24 | from ..._meta import API_VTAG as VTAG |
23 | 25 | from ...login.decorators import login_required |
|
37 | 39 | routes = web.RouteTableDef() |
38 | 40 |
|
39 | 41 |
|
| 42 | +def _create_json_response_from_page(page: Page[ItemT]): |
| 43 | + return web.Response( |
| 44 | + text=page.model_dump_json(**RESPONSE_MODEL_POLICY), |
| 45 | + content_type=MIMETYPE_APPLICATION_JSON, |
| 46 | + ) |
| 47 | + |
| 48 | + |
40 | 49 | @routes.post(f"/{VTAG}/functions", name="register_function") |
41 | 50 | @login_required |
42 | 51 | @handle_rest_requests_exceptions |
@@ -143,7 +152,7 @@ async def list_functions(request: web.Request) -> web.Response: |
143 | 152 | offset=query_params.offset, |
144 | 153 | ) |
145 | 154 | ) |
146 | | - return envelope_json_response(page) |
| 155 | + return _create_json_response_from_page(page) |
147 | 156 |
|
148 | 157 |
|
149 | 158 | @routes.get( |
|
0 commit comments