mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-24 00:00:16 +02:00
Move TypedHeader to axum-extra (#1850)
Co-authored-by: Michael Scofield <[email protected]> Co-authored-by: Jonas Platte <[email protected]>
This commit is contained in:
co-authored by
Michael Scofield
Jonas Platte
parent
173f9f72b0
commit
877e3fe4de
@@ -77,10 +77,8 @@ async fn main() {
|
||||
// run it with hyper
|
||||
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
|
||||
tracing::debug!("listening on {}", addr);
|
||||
axum::Server::bind(&addr)
|
||||
.serve(app.into_make_service())
|
||||
.await
|
||||
.unwrap();
|
||||
let listener = tokio::net::TcpListener::bind(addr).await.unwrap();
|
||||
axum::serve(listener, app).await.unwrap();
|
||||
}
|
||||
|
||||
async fn create_user(
|
||||
|
||||
@@ -85,10 +85,8 @@ async fn main() {
|
||||
// run it with hyper
|
||||
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
|
||||
tracing::debug!("listening on {}", addr);
|
||||
axum::Server::bind(&addr)
|
||||
.serve(app.into_make_service())
|
||||
.await
|
||||
.unwrap();
|
||||
let listener = tokio::net::TcpListener::bind(addr).await.unwrap();
|
||||
axum::serve(listener, app).await.unwrap();
|
||||
}
|
||||
|
||||
async fn create_user(
|
||||
|
||||
@@ -5,8 +5,8 @@ edition = "2021"
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
axum = { path = "../../axum", features = ["headers"] }
|
||||
headers = "0.3"
|
||||
axum = { path = "../../axum" }
|
||||
axum-extra = { path = "../../axum-extra", features = ["typed-header"] }
|
||||
jsonwebtoken = "8.0"
|
||||
once_cell = "1.8"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
|
||||
@@ -8,13 +8,16 @@
|
||||
|
||||
use axum::{
|
||||
async_trait,
|
||||
extract::{FromRequestParts, TypedHeader},
|
||||
headers::{authorization::Bearer, Authorization},
|
||||
extract::FromRequestParts,
|
||||
http::{request::Parts, StatusCode},
|
||||
response::{IntoResponse, Response},
|
||||
routing::{get, post},
|
||||
Json, RequestPartsExt, Router,
|
||||
};
|
||||
use axum_extra::{
|
||||
headers::{authorization::Bearer, Authorization},
|
||||
TypedHeader,
|
||||
};
|
||||
use jsonwebtoken::{decode, encode, DecodingKey, EncodingKey, Header, Validation};
|
||||
use once_cell::sync::Lazy;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -6,8 +6,8 @@ publish = false
|
||||
|
||||
[dependencies]
|
||||
async-session = "3.0.0"
|
||||
axum = { path = "../../axum", features = ["headers"] }
|
||||
headers = "0.3"
|
||||
axum = { path = "../../axum" }
|
||||
axum-extra = { path = "../../axum-extra", features = ["typed-header"] }
|
||||
http = "0.2"
|
||||
oauth2 = "4.1"
|
||||
# Use Rustls because it makes it easier to cross-compile on CI
|
||||
|
||||
@@ -11,14 +11,13 @@
|
||||
use async_session::{MemoryStore, Session, SessionStore};
|
||||
use axum::{
|
||||
async_trait,
|
||||
extract::{
|
||||
rejection::TypedHeaderRejectionReason, FromRef, FromRequestParts, Query, State, TypedHeader,
|
||||
},
|
||||
extract::{FromRef, FromRequestParts, Query, State},
|
||||
http::{header::SET_COOKIE, HeaderMap},
|
||||
response::{IntoResponse, Redirect, Response},
|
||||
routing::get,
|
||||
RequestPartsExt, Router,
|
||||
};
|
||||
use axum_extra::{headers, typed_header::TypedHeaderRejectionReason, TypedHeader};
|
||||
use http::{header, request::Parts};
|
||||
use oauth2::{
|
||||
basic::BasicClient, reqwest::async_http_client, AuthUrl, AuthorizationCode, ClientId,
|
||||
|
||||
@@ -6,7 +6,8 @@ publish = false
|
||||
|
||||
[dependencies]
|
||||
async-session = "3.0.0"
|
||||
axum = { path = "../../axum", features = ["headers"] }
|
||||
axum = { path = "../../axum" }
|
||||
axum-extra = { path = "../../axum-extra", features = ["typed-header"] }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
tokio = { version = "1.0", features = ["full"] }
|
||||
tracing = "0.1"
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
use async_session::{MemoryStore, Session, SessionStore as _};
|
||||
use axum::{
|
||||
async_trait,
|
||||
extract::{FromRef, FromRequestParts, TypedHeader},
|
||||
headers::Cookie,
|
||||
extract::{FromRef, FromRequestParts},
|
||||
http::{
|
||||
self,
|
||||
header::{HeaderMap, HeaderValue},
|
||||
@@ -19,6 +18,7 @@ use axum::{
|
||||
routing::get,
|
||||
RequestPartsExt, Router,
|
||||
};
|
||||
use axum_extra::{headers::Cookie, TypedHeader};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt::Debug;
|
||||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
||||
|
||||
@@ -5,7 +5,8 @@ edition = "2021"
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
axum = { path = "../../axum", features = ["headers"] }
|
||||
axum = { path = "../../axum" }
|
||||
axum-extra = { path = "../../axum-extra", features = ["typed-header"] }
|
||||
futures = "0.3"
|
||||
headers = "0.3"
|
||||
tokio = { version = "1.0", features = ["full"] }
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
//! ```
|
||||
|
||||
use axum::{
|
||||
extract::TypedHeader,
|
||||
response::sse::{Event, Sse},
|
||||
routing::get,
|
||||
Router,
|
||||
};
|
||||
use axum_extra::{headers, TypedHeader};
|
||||
use futures::stream::{self, Stream};
|
||||
use std::{convert::Infallible, path::PathBuf, time::Duration};
|
||||
use tokio_stream::StreamExt as _;
|
||||
|
||||
@@ -5,7 +5,8 @@ edition = "2021"
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
axum = { path = "../../axum", features = ["ws", "headers"] }
|
||||
axum = { path = "../../axum", features = ["ws"] }
|
||||
axum-extra = { path = "../../axum-extra", features = ["typed-header"] }
|
||||
futures = "0.3"
|
||||
futures-util = { version = "0.3", default-features = false, features = ["sink", "std"] }
|
||||
headers = "0.3"
|
||||
|
||||
@@ -17,14 +17,12 @@
|
||||
//! ```
|
||||
|
||||
use axum::{
|
||||
extract::{
|
||||
ws::{Message, WebSocket, WebSocketUpgrade},
|
||||
TypedHeader,
|
||||
},
|
||||
extract::ws::{Message, WebSocket, WebSocketUpgrade},
|
||||
response::IntoResponse,
|
||||
routing::get,
|
||||
Router,
|
||||
};
|
||||
use axum_extra::TypedHeader;
|
||||
|
||||
use std::borrow::Cow;
|
||||
use std::ops::ControlFlow;
|
||||
|
||||
Reference in New Issue
Block a user