Remove once_cell from jwt example (#3014)

Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>
This commit is contained in:
Hayashi Mikihiro 2024-11-12 01:57:10 +09:00 committed by GitHub
parent 59a2960e42
commit 0774e59704
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 3 deletions

View file

@ -8,7 +8,6 @@ publish = false
axum = { path = "../../axum" } axum = { path = "../../axum" }
axum-extra = { path = "../../axum-extra", features = ["typed-header"] } axum-extra = { path = "../../axum-extra", features = ["typed-header"] }
jsonwebtoken = "9.3" jsonwebtoken = "9.3"
once_cell = "1.8"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0" serde_json = "1.0"
tokio = { version = "1.0", features = ["full"] } tokio = { version = "1.0", features = ["full"] }

View file

@ -18,10 +18,10 @@ use axum_extra::{
TypedHeader, TypedHeader,
}; };
use jsonwebtoken::{decode, encode, DecodingKey, EncodingKey, Header, Validation}; use jsonwebtoken::{decode, encode, DecodingKey, EncodingKey, Header, Validation};
use once_cell::sync::Lazy;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_json::json; use serde_json::json;
use std::fmt::Display; use std::fmt::Display;
use std::sync::LazyLock;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
// Quick instructions // Quick instructions
@ -50,7 +50,7 @@ use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
// -H 'Authorization: Bearer blahblahblah' \ // -H 'Authorization: Bearer blahblahblah' \
// http://localhost:3000/protected // http://localhost:3000/protected
static KEYS: Lazy<Keys> = Lazy::new(|| { static KEYS: LazyLock<Keys> = LazyLock::new(|| {
let secret = std::env::var("JWT_SECRET").expect("JWT_SECRET must be set"); let secret = std::env::var("JWT_SECRET").expect("JWT_SECRET must be set");
Keys::new(secret.as_bytes()) Keys::new(secret.as_bytes())
}); });