refactor: simplification ToAuthorizationLayer -> IntoLayer

This commit is contained in:
cduvray 2023-08-14 08:02:56 +02:00
parent 0fbdc0df84
commit 50c2ecac38
5 changed files with 20 additions and 22 deletions

View file

@ -11,7 +11,7 @@ use std::{
use axum::{response::Response, routing::get, Json, Router};
use http::{header::AUTHORIZATION, Request, StatusCode};
use hyper::Body;
use jwt_authorizer::{JwtAuthorizer, JwtClaims, Refresh, RefreshStrategy, ToAuthorizationLayer};
use jwt_authorizer::{IntoLayer, JwtAuthorizer, JwtClaims, Refresh, RefreshStrategy};
use lazy_static::lazy_static;
use serde::{Deserialize, Serialize};
use serde_json::Value;
@ -104,7 +104,7 @@ async fn app(jwt_auth: JwtAuthorizer<User>) -> Router {
let protected_route: Router = Router::new()
.route("/protected", get(protected_handler))
.route("/protected-with-user", get(protected_with_user))
.layer(jwt_auth.to_layer().await.unwrap());
.layer(jwt_auth.into_layer().await.unwrap());
Router::new().merge(pub_route).merge(protected_route)
}