mirror of
https://github.com/tokio-rs/axum.git
synced 2024-11-21 22:56:46 +01:00
Remove once_cell from jwt example (#3014)
Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>
This commit is contained in:
parent
59a2960e42
commit
0774e59704
2 changed files with 2 additions and 3 deletions
|
@ -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"] }
|
||||||
|
|
|
@ -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())
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue