Compare commits

...

4 commits

Author SHA1 Message Date
Astro 242a4f41cb Cargo.lock: update 2024-03-27 02:23:28 +01:00
Astro 994f8b1b6f update dependencies axum to 0.7, reqwest to 0.12 2024-03-27 02:19:08 +01:00
Astro 99e65befb9 flake.lock: Update
Flake lock file updates:

• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/98b00b6947a9214381112bdb6f89c25498db4959' (2024-02-22)
  → 'github:NixOS/nixpkgs/c726225724e681b3626acc941c6f95d2b0602087' (2024-03-25)
• Updated input 'utils':
    'github:numtide/flake-utils/1ef2e671c3b0c19053962c07dbda38332dcebf26' (2024-01-15)
  → 'github:numtide/flake-utils/b1d9ab70662946ef0850d488da1c9019f3a9752a' (2024-03-11)
2024-03-27 00:23:42 +01:00
Astro d94140c443 flake.lock: Update
Flake lock file updates:

• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/aa9d4729cbc99dabacb50e3994dcefb3ea0f7447' (2023-12-14)
  → 'github:NixOS/nixpkgs/98b00b6947a9214381112bdb6f89c25498db4959' (2024-02-22)
• Updated input 'utils':
    'github:numtide/flake-utils/4022d587cbbfd70fe950c1e2083a02621806a725' (2023-12-04)
  → 'github:numtide/flake-utils/1ef2e671c3b0c19053962c07dbda38332dcebf26' (2024-01-15)
2024-02-23 01:58:48 +01:00
5 changed files with 391 additions and 348 deletions

697
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -6,20 +6,19 @@ repository = "https://github.com/astro/buzzrelay"
homepage = "https://relay.fedi.buzz"
[dependencies]
axum = "0.6"
axum-macros = "0.3"
axum-extra = { version = "0.4", features = ["spa"] }
axum = "0.7"
tower-http = { version = "0.5", features = ["fs"] }
tokio = { version = "1", features = ["full", "time"] }
tracing = "*"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
serde_yaml = "0.9"
reqwest = { version = "0.11", features = ["json", "stream"] }
reqwest = { version = "0.12", features = ["json", "stream"] }
sigh = "1.0"
http_digest_headers = { version = "0.1.0", default-features = false, features = ["use_openssl"] }
thiserror = "1"
http = "0.2"
http = "1"
chrono = "0.4"
eventsource-stream = "0.2"
futures = "0.3"
@ -28,7 +27,7 @@ systemd = "0.10"
metrics = "0.21"
metrics-util = "0.15"
metrics-exporter-prometheus = "0.12"
deunicode = "1.3"
deunicode = "1.4"
urlencoding = "2"
httpdate = "1"
redis = { version = "0.23", features = ["tokio-comp", "connection-manager"] }

View file

@ -23,11 +23,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1702539185,
"narHash": "sha256-KnIRG5NMdLIpEkZTnN5zovNYc0hhXjAgv6pfd5Z4c7U=",
"lastModified": 1711370797,
"narHash": "sha256-2xu0jVSjuKhN97dqc4bVtvEH52Rwh6+uyI1XCnzoUyI=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "aa9d4729cbc99dabacb50e3994dcefb3ea0f7447",
"rev": "c726225724e681b3626acc941c6f95d2b0602087",
"type": "github"
},
"original": {
@ -64,11 +64,11 @@
"systems": "systems"
},
"locked": {
"lastModified": 1701680307,
"narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=",
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "4022d587cbbfd70fe950c1e2083a02621806a725",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {

View file

@ -2,9 +2,9 @@ use std::sync::Arc;
use axum::{
async_trait,
body::{Bytes, HttpBody},
body::{Bytes, Body},
extract::{FromRef, FromRequest},
http::{header::CONTENT_TYPE, Request, StatusCode}, BoxError,
http::{header::CONTENT_TYPE, Request, StatusCode},
};
use http_digest_headers::DigestHeader;
use sigh::{Signature, PublicKey, Key, PrivateKey};
@ -28,17 +28,14 @@ pub struct Endpoint<'a> {
}
#[async_trait]
impl<'a, S, B> FromRequest<S, B> for Endpoint<'a>
impl<'a, S> FromRequest<S> for Endpoint<'a>
where
B: HttpBody + Send + 'static,
B::Data: Send,
B::Error: Into<BoxError>,
S: Send + Sync,
Arc<reqwest::Client>: FromRef<S>,
{
type Rejection = (StatusCode, String);
async fn from_request(req: Request<B>, state: &S) -> Result<Self, Self::Rejection> {
async fn from_request(req: Request<Body>, state: &S) -> Result<Self, Self::Rejection> {
// validate content-type
let content_type = if let Some(content_type) = req.headers()
.get(CONTENT_TYPE)

View file

@ -4,7 +4,7 @@ use axum::{
response::{IntoResponse, Response},
routing::get, Json, Router,
};
use axum_extra::routing::SpaRouter;
use tower_http::services::ServeDir;
use metrics::increment_counter;
use metrics_util::MetricKindMask;
use metrics_exporter_prometheus::PrometheusBuilder;
@ -423,11 +423,11 @@ async fn main() {
recorder.render().into_response()
}))
.with_state(state)
.merge(SpaRouter::new("/", "static"));
.fallback_service(ServeDir::new("static"));
let addr = SocketAddr::from(([127, 0, 0, 1], config.listen_port));
let server = axum::Server::bind(&addr)
.serve(app.into_make_service());
let listener = tokio::net::TcpListener::bind(addr).await.unwrap();
let server = axum::serve(listener, app.into_make_service());
tracing::info!("serving on {}", addr);
systemd::daemon::notify(false, [(systemd::daemon::STATE_READY, "1")].iter())