Skip to content

Commit

Permalink
remove once_cell and use std::sync::LazyLock
Browse files Browse the repository at this point in the history
Signed-off-by: Hayashi Mikihiro <[email protected]>
  • Loading branch information
Hmikihiro committed Nov 2, 2024
1 parent 280d16a commit 74c2ac7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
1 change: 0 additions & 1 deletion examples/jwt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
4 changes: 2 additions & 2 deletions examples/jwt/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -50,7 +50,7 @@ use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
// -H 'Authorization: Bearer blahblahblah' \
// 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");
Keys::new(secret.as_bytes())
});
Expand Down

0 comments on commit 74c2ac7

Please sign in to comment.