From 0774e597040014dfe14bfefa4651942030992d4d Mon Sep 17 00:00:00 2001 From: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> Date: Tue, 12 Nov 2024 01:57:10 +0900 Subject: [PATCH] Remove once_cell from jwt example (#3014) 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 54378fe3..c36511a2 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 8b7a7cbe..f7877d74 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()) });