Add vary header

This commit is contained in:
Adam Hopkins 2023-09-18 10:39:45 +03:00
parent 86a414fd58
commit 8ad0a153c5
No known key found for this signature in database
GPG Key ID: 9F85EE6C807303FB
3 changed files with 4 additions and 4 deletions

View File

@ -110,7 +110,6 @@ def organize_docobjects(package_name: str) -> dict[str, str]:
docobjects = _extract_docobjects(package_name)
page_registry: defaultdict[str, list[str]] = defaultdict(list)
for module, docobject in docobjects.items():
print(f"{module=}")
builder = Builder(name="Partial")
_docobject_to_html(docobject, builder)
ref = module.rsplit(".", module.count(".") - 1)[0]

View File

@ -5,7 +5,6 @@ from mistune.markdown import Markdown
DIRECTIVE_PATTERN = r":(?:class|func|meth|attr|exc|mod|data|const|obj|keyword|option|cmdoption|envvar):`(?P<ref>sanic\.[^`]+)`" # noqa: E501
def _parse_inline_directive(inline, m: re.Match, state):
print("inline_directive.py: _parse_inline_directive", m.group("ref"))
state.append_token(
{
"type": "inline_directive",
@ -16,5 +15,4 @@ def _parse_inline_directive(inline, m: re.Match, state):
return m.end()
def inline_directive(md: Markdown):
print("Registering inline_directive")
md.inline.register("inline_directive", DIRECTIVE_PATTERN, _parse_inline_directive, before="escape",)

View File

@ -62,7 +62,10 @@ def create_app(root: Path) -> Sanic:
language: str,
path: str = "",
):
return html(page_renderer.render(request, language, path))
return html(
page_renderer.render(request, language, path),
headers={"vary": "hx-request"},
)
@app.on_request
async def set_language(request: Request):