feat: axum type 0.7

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
Kasper Juul Hermansen 2023-10-31 22:03:48 +01:00
parent 393be43db1
commit 13756ba6ac
Signed by: kjuulh
GPG Key ID: 57B6E1465221F912
6 changed files with 364 additions and 195 deletions

520
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -13,8 +13,8 @@ tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
clap = {version = "4.4.7", features = ["derive", "env"]}
async-trait = {version = "0.1.74", features = []}
axum = {version = "0.6.20", features = []}
axum-extra = {version = "0.8.0", features = ["cookie", "cookie-private"]}
axum = { git = "https://github.com/tokio-rs/axum", branch = "main", features = ["macros"] }
axum-extra = {git = "https://github.com/tokio-rs/axum", branch = "main" , features = ["cookie", "cookie-private", "typed-header"]}
axum-sessions = {version = "0.6.1", features = []}
async-sqlx-session = {version = "0.4.0", features = ["pg"]}

View File

@ -1,16 +1,15 @@
use std::fmt::Display;
use axum::extract::{FromRef, FromRequestParts, Query, State};
use axum::headers::authorization::Basic;
use axum::headers::{Authorization, Cookie};
use axum::http::request::Parts;
use axum::http::StatusCode;
use axum::response::{ErrorResponse, IntoResponse, Redirect};
use axum::routing::get;
use axum::{async_trait, Json, RequestPartsExt, Router, TypedHeader};
use axum::{async_trait, Json, RequestPartsExt, Router};
use axum_extra::headers::authorization::Basic;
use axum_extra::headers::{Authorization, Cookie};
use axum_extra::TypedHeader;
use serde::Deserialize;
use serde_json::json;

View File

@ -1,4 +1,4 @@
use std::net::SocketAddr;
use std::{net::SocketAddr, str::FromStr};
use axum::{
extract::{FromRef, State},
@ -58,13 +58,10 @@ async fn main() -> anyhow::Result<()> {
.with_state(state)
.nest("/auth", AuthController::new_router(auth_service).await?);
let addr = SocketAddr::from(([127, 0, 0, 1], 3001));
println!("listening on: {addr}");
println!("open browser at: http://localhost:3001/auth/zitadel");
axum::Server::bind(&addr)
.serve(app.into_make_service())
.await
.unwrap();
let addr = SocketAddr::from_str(&format!("{}:{}", "127.0.0.1", "3000"))?;
let listener = tokio::net::TcpListener::bind(&addr).await?;
axum::serve(listener, app).await?;
Ok(())
}

View File

@ -1,4 +1,4 @@
use std::net::SocketAddr;
use std::{net::SocketAddr, str::FromStr};
use axum::{
extract::{FromRef, State},
@ -57,10 +57,11 @@ async fn main() -> anyhow::Result<()> {
let addr = SocketAddr::from(([127, 0, 0, 1], 3001));
println!("listening on: {addr}");
println!("open browser at: http://localhost:3001/auth/zitadel");
axum::Server::bind(&addr)
.serve(app.into_make_service())
.await
.unwrap();
let addr = SocketAddr::from_str(&format!("{}:{}", "127.0.0.1", "3000"))?;
let listener = tokio::net::TcpListener::bind(&addr).await?;
axum::serve(listener, app).await?;
Ok(())
}