question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Proposal: "http.response.template" extension.

See original GitHub issue

In situations where an application server is happens to be returning template-rendered data, it’s hugely valuable for the template and context information to be sent in the ASGI messaging, alongside the actual rendered content.

Right now we use this in Starlette, so that an ASGI-based test client is able to provide response.template and response.context information back to the user.

Formalising this, would allow us to support this kind of usage:

# This client calls directly into an ASGI app, rather than making network requests.
client = httpx.AsyncClient(app=app)

# Make the request.
response = await client.get("http://testserver/")
assert response.status_code == 200

# This information is made available through the "http.response.template" extension.
# Ensure that we're on the homepage, and that no messages are displayed.
assert response.template == "homepage.html"
assert response.context["user_messages"] == []

It’s not totally obvious if an extension such as this should strictly focus on template/context info, or if there’s a more general purpose “extra info” extension that ought to be considered here, but I figure it’s worth opening this for discussion.

Informally, here’s ~how the existing Starlette implementation looks…

# If the ASGI `http.response.template` extension is supported,
# then we can send this style of message...
{
    "type": "http.response.template",
    "template": "homepage.html",
    "context": {"user_messages": []}
}

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:16 (15 by maintainers)

github_iconTop GitHub Comments

2reactions
davidismcommented, Nov 15, 2019

It seems too narrow to define this specifically for templates. Perhaps a “execution_info” extension instead, so an app could provide whatever they want back to the test client.

1reaction
tomchristiecommented, Dec 3, 2019

Happily, yup. I’m not in any great rush but I’ll aim to get around to it sometime.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Response templates - Product Documentation | ServiceNow
Response templates (formerly known as templated snippets) are reusable messages that can be copied to case or task forms to provide quick and...
Read more >
How to Write a Great Website RFP - New Media Campaigns
1. Introduce your organization and the purpose of the RFP. State not only what you want the service provider to do but also...
Read more >
40+ Best Request for Proposal Templates & Examples (RPF ...
Download professionally written Request for Proposal Templates and Examples. ... If organizations really want to get an RFP response from the companies, ...
Read more >
Design-Build (DB) Request for Proposal (RFP) Template with ...
100% Draft DB Construction Documents and written responses to the NPS DB Design ... Extension of the contract time will be granted only...
Read more >
papercraft/README.md at master · digital-fabric/papercraft · GitHub
Papercraft includes built-in support for rendering Markdown (using Kramdown), as well as support for creating template extensions in order to allow the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found