From 74c2ac72f9e1f200f1e9eecd35dc257e97e76eb8 Mon Sep 17 00:00:00 2001 From: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> Date: Sat, 2 Nov 2024 12:52:11 +0000 Subject: [PATCH] remove once_cell and use std::sync::LazyLock Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> --- examples/jwt/Cargo.toml | 1 - examples/jwt/src/main.rs | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/jwt/Cargo.toml b/examples/jwt/Cargo.toml index 54378fe3ee..c36511a27d 100644 --- a/examples/jwt/Cargo.toml +++ b/examples/jwt/Cargo.toml @@ -8,7 +8,6 @@ publish = false axum = { path = "../../axum" } axum-extra = { path = "../../axum-extra", features = ["typed-header"] } jsonwebtoken = "9.3" -once_cell = "1.8" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" tokio = { version = "1.0", features = ["full"] } diff --git a/examples/jwt/src/main.rs b/examples/jwt/src/main.rs index 8b7a7cbe6b..f7877d745f 100644 --- a/examples/jwt/src/main.rs +++ b/examples/jwt/src/main.rs @@ -18,10 +18,10 @@ use axum_extra::{ TypedHeader, }; use jsonwebtoken::{decode, encode, DecodingKey, EncodingKey, Header, Validation}; -use once_cell::sync::Lazy; use serde::{Deserialize, Serialize}; use serde_json::json; use std::fmt::Display; +use std::sync::LazyLock; use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; // Quick instructions @@ -50,7 +50,7 @@ use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; // -H 'Authorization: Bearer blahblahblah' \ // http://localhost:3000/protected -static KEYS: Lazy = Lazy::new(|| { +static KEYS: LazyLock = LazyLock::new(|| { let secret = std::env::var("JWT_SECRET").expect("JWT_SECRET must be set"); Keys::new(secret.as_bytes()) });