Losing my mind a little here.
I'm attempting to pass a set of keys into my hyper service function in order to verify JWTs. I don't want to regenerate a HashMap and call on Google's servers every request.
When I try to do so: I'm getting a temporary value dropped while borrowed error. I've tried to mark the hashmap as static, wrap the function call in a LazyLock, and use join handles to ensure that the HashMap cannot go out of scope, but I can't seem to get anything to work.
Here's a rough outline of what I have.
//in main
tokio::task::spawn(async move {
google_keys: &HashMap<String, (String, String)> = &jwt::get_google_auth_keys()
loop{
g_keys = google_keys;
...
tokio::task::spawn( async move {
...
serve_connection(io, service_fn(|req: Request<hyper::body::Incoming>| async {
service(req, g_keys).await
})
}
});
I tried using Axum instead of Hyper but I'm doing self-signed TLS and wasn't able to effectively debug it. If you think I'm using totally the wrong tools let me know.