use axum::{
extract::{FromRequestParts, Query},
http::{request::Parts, StatusCode},
RequestPartsExt,
};
use serde::Deserialize;
#[derive(Deserialize, Debug)]
pub struct Claims {
pub user_id: i32,
}
#[axum::async_trait]
impl<T> FromRequestParts<T> for Claims {
type Rejection = StatusCode;
async fn from_request_parts(parts: &mut Parts, _state: &T) -> Result<Self, Self::Rejection> {
match parts.extract().await {
Ok(Query(claims)) => Ok(claims),
Err(err) => {
tracing::debug!(%err, "Autharization failed");
Err(StatusCode::UNAUTHORIZED)