update axum and reqwest dependencies to http-1.0
This commit is contained in:
parent
213858f9ac
commit
3a14867a75
File diff suppressed because it is too large
Load Diff
|
@ -6,7 +6,7 @@ edition = "2021"
|
|||
[dependencies]
|
||||
futures = "0.3"
|
||||
tokio = { version = "1", features = ["full", "tracing"] }
|
||||
reqwest = { version = "0.11", features = ["json", "deflate", "gzip", "trust-dns"] }
|
||||
reqwest = { version = "0.12", features = ["json", "deflate", "gzip", "trust-dns"] }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
chrono = "0.4"
|
||||
|
|
|
@ -11,7 +11,7 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
|||
serde = { version = "1", features = ["serde_derive"] }
|
||||
serde_json = "1"
|
||||
serde_yaml = "0.9"
|
||||
reqwest = { version = "0.11", features = ["json", "stream"] }
|
||||
reqwest = { version = "0.12", features = ["json", "stream"] }
|
||||
sigh = "1"
|
||||
thiserror = "1"
|
||||
http = "0.2"
|
||||
|
|
|
@ -15,7 +15,7 @@ bb8 = "0.8"
|
|||
redis = { version = "0.23", features = ["tokio-comp", "connection-manager"] }
|
||||
tracing = "0.1"
|
||||
systemd = "0.10"
|
||||
reqwest = { version = "0.11", features = ["json", "deflate", "gzip", "stream"] }
|
||||
reqwest = { version = "0.12", features = ["json", "deflate", "gzip", "stream"] }
|
||||
eventsource-stream = "0.2"
|
||||
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
||||
inotify = "0.10"
|
||||
|
@ -24,6 +24,6 @@ url = "2"
|
|||
metrics = "0.20"
|
||||
sigh = "1"
|
||||
http_digest_headers = { version="0.1.0", default-features = false, features = ["use_openssl"] }
|
||||
http = "0.2"
|
||||
http = "1"
|
||||
thiserror = "1"
|
||||
httpdate = "1"
|
||||
|
|
|
@ -12,14 +12,12 @@ chrono = "0.4"
|
|||
redis = { version = "0.23", features = ["tokio-comp", "connection-manager"] }
|
||||
tracing = "0.1"
|
||||
cave = { path = "../cave" }
|
||||
hyper = { version = "0.14", features = ["stream"] }
|
||||
axum = "0.5"
|
||||
axum-macros = "0.2"
|
||||
axum-extra = { version = "0.3", features = ["spa"] }
|
||||
axum = "0.7"
|
||||
http-body = "0.4"
|
||||
askama = "0.11"
|
||||
metrics = "0.20"
|
||||
metrics-util = "0.14"
|
||||
metrics-exporter-prometheus = "0.11"
|
||||
reqwest = { version = "0.11", features = ["json", "trust-dns"] }
|
||||
reqwest = { version = "0.12", features = ["json", "trust-dns"] }
|
||||
urlencoding = "1"
|
||||
tower-http = { version = "0.5", features = ["fs"] }
|
||||
|
|
|
@ -1,22 +1,19 @@
|
|||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
ops::Deref,
|
||||
net::SocketAddr,
|
||||
collections::{HashMap, HashSet}, net::SocketAddr, ops::Deref, pin::Pin
|
||||
};
|
||||
use askama::Template;
|
||||
use axum::{
|
||||
async_trait,
|
||||
Extension,
|
||||
extract::{self, RequestParts, FromRequest},
|
||||
http::{StatusCode, Request, Response},
|
||||
extract::{self, FromRequestParts},
|
||||
http::{StatusCode, Request, Response, request::Parts},
|
||||
response::IntoResponse,
|
||||
routing::get,
|
||||
Router,
|
||||
middleware::{Next, self},
|
||||
body::{Body, Bytes},
|
||||
};
|
||||
use axum_extra::routing::SpaRouter;
|
||||
use futures::{stream, StreamExt};
|
||||
use futures::{stream, Future, StreamExt};
|
||||
use futures::future::{join, join_all};
|
||||
use cave::{
|
||||
firehose::FirehoseFactory,
|
||||
|
@ -29,6 +26,7 @@ use crate::{
|
|||
html_template::HtmlTemplate,
|
||||
trends::{TrendAnalyzer, TrendsResults},
|
||||
};
|
||||
use tower_http::services::ServeDir;
|
||||
|
||||
mod token_donate;
|
||||
mod token_collect;
|
||||
|
@ -84,14 +82,17 @@ impl ServerState {
|
|||
}
|
||||
|
||||
#[async_trait]
|
||||
impl<B> FromRequest<B> for ServerState
|
||||
impl<S> FromRequestParts<S> for ServerState
|
||||
where
|
||||
B: Send,
|
||||
S: Send + Sync,
|
||||
{
|
||||
type Rejection = (StatusCode, String);
|
||||
|
||||
async fn from_request(req: &mut RequestParts<B>) -> Result<Self, Self::Rejection> {
|
||||
let Extension(state) = Extension::<ServerState>::from_request(req)
|
||||
async fn from_request_parts<'life0, 'life1>(
|
||||
parts: &'life0 mut Parts,
|
||||
state: &'life1 S
|
||||
) -> Result<Self, Self::Rejection> {
|
||||
let Extension(state) = Extension::<ServerState>::from_request_parts(parts, state)
|
||||
.await
|
||||
.map_err(internal_error)?;
|
||||
|
||||
|
@ -142,7 +143,7 @@ impl TrendsPage {
|
|||
async fn trends_page(
|
||||
state: ServerState,
|
||||
language: Option<String>,
|
||||
) -> Response<UnsyncBoxBody<Bytes, axum::Error>> {
|
||||
) -> Response<Body> {
|
||||
let lang = if language.is_some() { "some" } else { "any" };
|
||||
let page = TrendsPage::generate(language, state)
|
||||
.await;
|
||||
|
@ -151,20 +152,20 @@ async fn trends_page(
|
|||
res
|
||||
}
|
||||
|
||||
async fn home(Extension(state): Extension<ServerState>) -> Response<UnsyncBoxBody<Bytes, axum::Error>> {
|
||||
async fn home(Extension(state): Extension<ServerState>) -> Response<Body> {
|
||||
trends_page(state, None).await
|
||||
}
|
||||
|
||||
async fn in_language(
|
||||
Extension(state): Extension<ServerState>,
|
||||
extract::Path(language): extract::Path<String>,
|
||||
) -> Response<UnsyncBoxBody<Bytes, axum::Error>> {
|
||||
) -> Response<Body> {
|
||||
trends_page(state, Some(language)).await
|
||||
}
|
||||
|
||||
async fn streaming_api(
|
||||
Extension(firehose_factory): Extension<FirehoseFactory>,
|
||||
) -> impl IntoResponse {
|
||||
) -> Response<Body> {
|
||||
let firehose = firehose_factory.produce()
|
||||
.await
|
||||
.expect("firehose");
|
||||
|
@ -179,19 +180,19 @@ async fn streaming_api(
|
|||
Ok(b"\n\n".to_vec()),
|
||||
].into_iter()).boxed())
|
||||
);
|
||||
let body = axum::body::boxed(hyper::body::Body::wrap_stream(stream));
|
||||
let body = Body::from_stream(stream);
|
||||
|
||||
Response::builder()
|
||||
.status(200)
|
||||
.header("content-type", "text/event-stream")
|
||||
.header("cache-control", "no-store")
|
||||
.body(body)
|
||||
.body(body.into())
|
||||
.expect("Response")
|
||||
}
|
||||
|
||||
async fn print_request(
|
||||
req: Request<Body>,
|
||||
next: Next<Body>,
|
||||
next: Next,
|
||||
) -> Result<impl IntoResponse, (StatusCode, String)> {
|
||||
tracing::info!(
|
||||
"{} {} {:?}",
|
||||
|
@ -230,12 +231,14 @@ pub async fn start(
|
|||
recorder.render().into_response()
|
||||
}))
|
||||
.layer(middleware::from_fn(print_request))
|
||||
.merge(SpaRouter::new("/assets", "assets"));
|
||||
.nest_service("/assets", ServeDir::new("assets"));
|
||||
|
||||
// run it
|
||||
let addr = SocketAddr::from(([0, 0, 0, 0], listen_port));
|
||||
axum::Server::bind(&addr)
|
||||
.serve(app.into_make_service())
|
||||
let listener = tokio::net::TcpListener::bind(&addr)
|
||||
.await
|
||||
.unwrap();
|
||||
axum::serve(listener, app.into_make_service())
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
|
|
|
@ -32,7 +32,6 @@ async fn main() {
|
|||
.user_agent(
|
||||
format!("{}/{} (+https://fedi.buzz/)", env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION"))
|
||||
)
|
||||
.trust_dns(true)
|
||||
.build()
|
||||
.expect("reqwest::Client");
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ edition = "2021"
|
|||
futures = "0.3"
|
||||
tokio = { version = "1", features = ["full", "tracing"] }
|
||||
tokio-uring = "0.4"
|
||||
reqwest = { version = "0.11", features = ["json", "deflate", "gzip", "trust-dns"] }
|
||||
reqwest = { version = "0.12", features = ["json", "deflate", "gzip", "trust-dns"] }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
chrono = "0.4"
|
||||
tracing = "0.1"
|
||||
|
|
|
@ -87,7 +87,6 @@ async fn run() {
|
|||
)
|
||||
.deflate(true)
|
||||
.gzip(true)
|
||||
.trust_dns(true)
|
||||
.build()
|
||||
.expect("reqwest::Client");
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ tracing = "0.1"
|
|||
cave = { path = "../cave" }
|
||||
url = "2"
|
||||
redis = { version = "0.23", features = ["tokio-comp", "connection-manager"] }
|
||||
reqwest = { version = "0.11" }
|
||||
reqwest = { version = "0.12" }
|
||||
http = "*"
|
||||
sigh = "*"
|
||||
metrics = "0.20"
|
||||
|
|
Loading…
Reference in New Issue