Guidance needed - how to store request context?
See original GitHub issueHi @goatslacker!
So I have a logger set up inside an express middleware, logging various things about the request.
One bit of information I’d like to add to the logs is - did the request hit a cold cache or not?
I have access to this information inside of my application code - inside of getComponent
. However there’s no great way that I can currently think of to thread this information along to other parts of the express app.
I’m thinking one way to do this would be to expose the express request
object to the context object passed into getComponent
https://github.com/airbnb/hypernova/blob/477257daad82e04f24ce851a9b3d21625354c783/src/utils/BatchManager.js#L90
Or maybe there’s just a better way to architect this?
Thanks!
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
The Request Context — Flask Documentation (2.2.x)
The request context keeps track of the request-level data during a request. Rather than passing the request object to each function that runs...
Read more >Understanding the Application and Request Contexts in ...
This post provides clarity on how the Application and Request contexts work in Flask.
Read more >Store Custom Data in Spring MVC Request Context
Store Custom Data in Spring MVC Request Context · Use HttpServletRequest or WebRequest · Annotate context bean with @RequestScope.
Read more >Context Management
Bound contexts are attached to some external data store (such as the HTTP Session or a manually propagated map) by associating the data...
Read more >Context | Android Developers
Return a new Context object for the current Context but whose storage APIs ... Retrieve, creating if needed, a new directory in which...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Why don’t we pass a reference to
res.locals
?I usually stick things on the response object (and never mutate the request)