You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just started using loco. I read the website and docs help documents in detail. I learned that AppContext can carry most global component objects, but I actually need to register some custom components, such as redis...
Since I just started using axum and loco recently, my understanding may not be correct. I read redis.rs in detail and did not find that it supports axum middle layer, etc. Then the way I thought of was to parse the connection information from the configuration normally, then initialize and obtain the redis client and put it in a static global variable. But I didn't find that loco has relevant configuration options. To save these custom objects.
Do I need to manage global variables myself in this case? I read the relevant code and manual of AppContext, and AppContext does not seem to support inserting objects by itself.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
How to modify AppContext or build global methods?
I just started using loco. I read the website and docs help documents in detail. I learned that AppContext can carry most global component objects, but I actually need to register some custom components, such as redis...
Since I just started using axum and loco recently, my understanding may not be correct. I read redis.rs in detail and did not find that it supports axum middle layer, etc. Then the way I thought of was to parse the connection information from the configuration normally, then initialize and obtain the redis client and put it in a static global variable. But I didn't find that loco has relevant configuration options. To save these custom objects.
Do I need to manage global variables myself in this case? I read the relevant code and manual of AppContext, and AppContext does not seem to support inserting objects by itself.
Beta Was this translation helpful? Give feedback.
All reactions