import asyncio
import errno
+import json
import logging
import os
import signal
# apply
await self.config_store.update(config_validated)
- # return success
- resp_text: Optional[str] = str(to_return) if to_return is not None else None
+ # serialize the response (the `to_return` object is a Dict/list/scalar, we want to return json)
+ resp_text: Optional[str] = json.dumps(to_return) if to_return is not None else None
+
+ # create the response and return it
res = web.Response(status=HTTPStatus.OK, text=resp_text, content_type="application/json")
res.headers.add("ETag", f'"{structural_etag(new_config)}"')
return res
def query(
original: Any, method: Literal["get", "delete", "put", "patch"], ptr: str, payload: Any
) -> Tuple[Any, Optional[Any]]:
- """
- Implements a modification API in the style of Caddy:
- https://caddyserver.com/docs/api
- """
-
########################################
# Prepare data we will be working on