mirror of
https://github.com/atuinsh/atuin.git
synced 2025-06-26 12:51:35 +02:00
chore(deps): update axum (#1637)
This commit is contained in:
parent
4b20544474
commit
bdcb143996
142
Cargo.lock
generated
142
Cargo.lock
generated
@ -282,15 +282,12 @@ dependencies = [
|
|||||||
"config",
|
"config",
|
||||||
"eyre",
|
"eyre",
|
||||||
"fs-err",
|
"fs-err",
|
||||||
"http 0.2.11",
|
|
||||||
"hyper 1.1.0",
|
|
||||||
"hyper-rustls",
|
|
||||||
"metrics",
|
"metrics",
|
||||||
"metrics-exporter-prometheus",
|
"metrics-exporter-prometheus",
|
||||||
"rand",
|
"rand",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"rustls",
|
"rustls",
|
||||||
"rustls-pemfile",
|
"rustls-pemfile 2.0.0",
|
||||||
"semver",
|
"semver",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
@ -338,18 +335,19 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "axum"
|
name = "axum"
|
||||||
version = "0.6.20"
|
version = "0.7.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf"
|
checksum = "1236b4b292f6c4d6dc34604bb5120d85c3fe1d1aa596bd5cc52ca054d13e7b9e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"axum-core",
|
"axum-core",
|
||||||
"bitflags 1.3.2",
|
|
||||||
"bytes",
|
"bytes",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"http 0.2.11",
|
"http 1.0.0",
|
||||||
"http-body 0.4.6",
|
"http-body 1.0.0",
|
||||||
"hyper 0.14.28",
|
"http-body-util",
|
||||||
|
"hyper 1.1.0",
|
||||||
|
"hyper-util",
|
||||||
"itoa",
|
"itoa",
|
||||||
"matchit",
|
"matchit",
|
||||||
"memchr",
|
"memchr",
|
||||||
@ -366,42 +364,50 @@ dependencies = [
|
|||||||
"tower",
|
"tower",
|
||||||
"tower-layer",
|
"tower-layer",
|
||||||
"tower-service",
|
"tower-service",
|
||||||
|
"tracing",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "axum-core"
|
name = "axum-core"
|
||||||
version = "0.3.4"
|
version = "0.4.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c"
|
checksum = "a15c63fd72d41492dc4f497196f5da1fb04fb7529e631d73630d1b491e47a2e3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"bytes",
|
"bytes",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"http 0.2.11",
|
"http 1.0.0",
|
||||||
"http-body 0.4.6",
|
"http-body 1.0.0",
|
||||||
|
"http-body-util",
|
||||||
"mime",
|
"mime",
|
||||||
|
"pin-project-lite",
|
||||||
"rustversion",
|
"rustversion",
|
||||||
|
"sync_wrapper",
|
||||||
"tower-layer",
|
"tower-layer",
|
||||||
"tower-service",
|
"tower-service",
|
||||||
|
"tracing",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "axum-server"
|
name = "axum-server"
|
||||||
version = "0.5.1"
|
version = "0.6.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "447f28c85900215cc1bea282f32d4a2f22d55c5a300afdfbc661c8d6a632e063"
|
checksum = "c1ad46c3ec4e12f4a4b6835e173ba21c25e484c9d02b49770bf006ce5367c036"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arc-swap",
|
"arc-swap",
|
||||||
"bytes",
|
"bytes",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"http 0.2.11",
|
"http 1.0.0",
|
||||||
"http-body 0.4.6",
|
"http-body 1.0.0",
|
||||||
"hyper 0.14.28",
|
"http-body-util",
|
||||||
|
"hyper 1.1.0",
|
||||||
|
"hyper-util",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"rustls",
|
"rustls",
|
||||||
"rustls-pemfile",
|
"rustls-pemfile 2.0.0",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-rustls",
|
"tokio-rustls",
|
||||||
|
"tower",
|
||||||
"tower-service",
|
"tower-service",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -1310,6 +1316,25 @@ dependencies = [
|
|||||||
"tracing",
|
"tracing",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "h2"
|
||||||
|
version = "0.4.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "31d030e59af851932b72ceebadf4a2b5986dba4c3b99dd2493f8273a0f151943"
|
||||||
|
dependencies = [
|
||||||
|
"bytes",
|
||||||
|
"fnv",
|
||||||
|
"futures-core",
|
||||||
|
"futures-sink",
|
||||||
|
"futures-util",
|
||||||
|
"http 1.0.0",
|
||||||
|
"indexmap 2.1.0",
|
||||||
|
"slab",
|
||||||
|
"tokio",
|
||||||
|
"tokio-util",
|
||||||
|
"tracing",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hashbrown"
|
name = "hashbrown"
|
||||||
version = "0.12.3"
|
version = "0.12.3"
|
||||||
@ -1436,10 +1461,17 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "http-range-header"
|
name = "http-body-util"
|
||||||
version = "0.3.1"
|
version = "0.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "add0ab9360ddbd88cfeb3bd9574a1d85cfdfa14db10b3e21d3700dbc4328758f"
|
checksum = "41cb79eb393015dadd30fc252023adb0b2400a0caee0fa2a077e6e21a551e840"
|
||||||
|
dependencies = [
|
||||||
|
"bytes",
|
||||||
|
"futures-util",
|
||||||
|
"http 1.0.0",
|
||||||
|
"http-body 1.0.0",
|
||||||
|
"pin-project-lite",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "httparse"
|
name = "httparse"
|
||||||
@ -1469,7 +1501,7 @@ dependencies = [
|
|||||||
"futures-channel",
|
"futures-channel",
|
||||||
"futures-core",
|
"futures-core",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"h2",
|
"h2 0.3.24",
|
||||||
"http 0.2.11",
|
"http 0.2.11",
|
||||||
"http-body 0.4.6",
|
"http-body 0.4.6",
|
||||||
"httparse",
|
"httparse",
|
||||||
@ -1490,8 +1522,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "fb5aa53871fc917b1a9ed87b683a5d86db645e23acb32c2e0785a353e522fb75"
|
checksum = "fb5aa53871fc917b1a9ed87b683a5d86db645e23acb32c2e0785a353e522fb75"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytes",
|
"bytes",
|
||||||
|
"futures-channel",
|
||||||
|
"futures-util",
|
||||||
|
"h2 0.4.2",
|
||||||
"http 1.0.0",
|
"http 1.0.0",
|
||||||
"http-body 1.0.0",
|
"http-body 1.0.0",
|
||||||
|
"httparse",
|
||||||
|
"httpdate",
|
||||||
|
"itoa",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"tokio",
|
"tokio",
|
||||||
]
|
]
|
||||||
@ -1505,13 +1543,29 @@ dependencies = [
|
|||||||
"futures-util",
|
"futures-util",
|
||||||
"http 0.2.11",
|
"http 0.2.11",
|
||||||
"hyper 0.14.28",
|
"hyper 0.14.28",
|
||||||
"log",
|
|
||||||
"rustls",
|
"rustls",
|
||||||
"rustls-native-certs",
|
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-rustls",
|
"tokio-rustls",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hyper-util"
|
||||||
|
version = "0.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bdea9aac0dbe5a9240d68cfd9501e2db94222c6dc06843e06640b9e07f0fdc67"
|
||||||
|
dependencies = [
|
||||||
|
"bytes",
|
||||||
|
"futures-channel",
|
||||||
|
"futures-util",
|
||||||
|
"http 1.0.0",
|
||||||
|
"http-body 1.0.0",
|
||||||
|
"hyper 1.1.0",
|
||||||
|
"pin-project-lite",
|
||||||
|
"socket2",
|
||||||
|
"tokio",
|
||||||
|
"tracing",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "idna"
|
name = "idna"
|
||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
@ -2515,7 +2569,7 @@ dependencies = [
|
|||||||
"encoding_rs",
|
"encoding_rs",
|
||||||
"futures-core",
|
"futures-core",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"h2",
|
"h2 0.3.24",
|
||||||
"http 0.2.11",
|
"http 0.2.11",
|
||||||
"http-body 0.4.6",
|
"http-body 0.4.6",
|
||||||
"hyper 0.14.28",
|
"hyper 0.14.28",
|
||||||
@ -2529,7 +2583,7 @@ dependencies = [
|
|||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"rustls",
|
"rustls",
|
||||||
"rustls-native-certs",
|
"rustls-native-certs",
|
||||||
"rustls-pemfile",
|
"rustls-pemfile 1.0.4",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"serde_urlencoded",
|
"serde_urlencoded",
|
||||||
@ -2672,7 +2726,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00"
|
checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"openssl-probe",
|
"openssl-probe",
|
||||||
"rustls-pemfile",
|
"rustls-pemfile 1.0.4",
|
||||||
"schannel",
|
"schannel",
|
||||||
"security-framework",
|
"security-framework",
|
||||||
]
|
]
|
||||||
@ -2686,6 +2740,22 @@ dependencies = [
|
|||||||
"base64 0.21.7",
|
"base64 0.21.7",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustls-pemfile"
|
||||||
|
version = "2.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "35e4980fa29e4c4b212ffb3db068a564cbf560e51d3944b7c88bd8bf5bec64f4"
|
||||||
|
dependencies = [
|
||||||
|
"base64 0.21.7",
|
||||||
|
"rustls-pki-types",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustls-pki-types"
|
||||||
|
version = "1.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9e9d979b3ce68192e42760c7810125eb6cf2ea10efae545a156063e61f314e2a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustls-webpki"
|
name = "rustls-webpki"
|
||||||
version = "0.101.7"
|
version = "0.101.7"
|
||||||
@ -3074,7 +3144,7 @@ dependencies = [
|
|||||||
"paste",
|
"paste",
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
"rustls",
|
"rustls",
|
||||||
"rustls-pemfile",
|
"rustls-pemfile 1.0.4",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"sha2",
|
"sha2",
|
||||||
@ -3559,17 +3629,15 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tower-http"
|
name = "tower-http"
|
||||||
version = "0.4.4"
|
version = "0.5.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "61c5bb1d698276a2443e5ecfabc1008bf15a36c12e6a7176e7bf089ea9131140"
|
checksum = "0da193277a4e2c33e59e09b5861580c33dd0a637c3883d0fa74ba40c0374af2e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.4.2",
|
"bitflags 2.4.2",
|
||||||
"bytes",
|
"bytes",
|
||||||
"futures-core",
|
"http 1.0.0",
|
||||||
"futures-util",
|
"http-body 1.0.0",
|
||||||
"http 0.2.11",
|
"http-body-util",
|
||||||
"http-body 0.4.6",
|
|
||||||
"http-range-header",
|
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"tower-layer",
|
"tower-layer",
|
||||||
"tower-service",
|
"tower-service",
|
||||||
|
@ -25,17 +25,14 @@ base64 = { workspace = true }
|
|||||||
rand = { workspace = true }
|
rand = { workspace = true }
|
||||||
tokio = { workspace = true }
|
tokio = { workspace = true }
|
||||||
async-trait = { workspace = true }
|
async-trait = { workspace = true }
|
||||||
axum = "0.6.4"
|
axum = "0.7.4"
|
||||||
axum-server = { version = "0.5.1", features = ["tls-rustls"] }
|
axum-server = { version = "0.6.0", features = ["tls-rustls"] }
|
||||||
http = "0.2"
|
|
||||||
hyper = "1.1"
|
|
||||||
hyper-rustls = "0.24"
|
|
||||||
fs-err = { workspace = true }
|
fs-err = { workspace = true }
|
||||||
tower = "0.4"
|
tower = "0.4"
|
||||||
tower-http = { version = "0.4", features = ["trace"] }
|
tower-http = { version = "0.5.1", features = ["trace"] }
|
||||||
reqwest = { workspace = true }
|
reqwest = { workspace = true }
|
||||||
rustls = "0.21"
|
rustls = "0.21"
|
||||||
rustls-pemfile = "1.0"
|
rustls-pemfile = "2.0"
|
||||||
argon2 = "0.5.3"
|
argon2 = "0.5.3"
|
||||||
semver = { workspace = true }
|
semver = { workspace = true }
|
||||||
metrics-exporter-prometheus = "0.12.1"
|
metrics-exporter-prometheus = "0.12.1"
|
||||||
|
@ -2,10 +2,9 @@ use std::{collections::HashMap, convert::TryFrom};
|
|||||||
|
|
||||||
use axum::{
|
use axum::{
|
||||||
extract::{Path, Query, State},
|
extract::{Path, Query, State},
|
||||||
http::HeaderMap,
|
http::{HeaderMap, StatusCode},
|
||||||
Json,
|
Json,
|
||||||
};
|
};
|
||||||
use http::StatusCode;
|
|
||||||
use metrics::counter;
|
use metrics::counter;
|
||||||
use time::{Month, UtcOffset};
|
use time::{Month, UtcOffset};
|
||||||
use tracing::{debug, error, instrument};
|
use tracing::{debug, error, instrument};
|
||||||
@ -215,7 +214,7 @@ pub async fn calendar<DB: Database>(
|
|||||||
error: ErrorResponse {
|
error: ErrorResponse {
|
||||||
reason: e.to_string().into(),
|
reason: e.to_string().into(),
|
||||||
},
|
},
|
||||||
status: http::StatusCode::BAD_REQUEST,
|
status: StatusCode::BAD_REQUEST,
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let period = match focus {
|
let period = match focus {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use atuin_common::api::{ErrorResponse, IndexResponse};
|
use atuin_common::api::{ErrorResponse, IndexResponse};
|
||||||
use atuin_server_database::Database;
|
use atuin_server_database::Database;
|
||||||
use axum::{extract::State, response::IntoResponse, Json};
|
use axum::{extract::State, http, response::IntoResponse, Json};
|
||||||
|
|
||||||
use crate::router::AppState;
|
use crate::router::AppState;
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
use axum::{response::IntoResponse, Json};
|
use axum::{http::StatusCode, response::IntoResponse, Json};
|
||||||
use http::StatusCode;
|
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
use axum::{extract::State, Json};
|
use axum::{extract::State, http::StatusCode, Json};
|
||||||
use http::StatusCode;
|
|
||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
|
|
||||||
use super::{ErrorResponse, ErrorResponseStatus, RespExt};
|
use super::{ErrorResponse, ErrorResponseStatus, RespExt};
|
||||||
|
@ -8,9 +8,9 @@ use argon2::{
|
|||||||
};
|
};
|
||||||
use axum::{
|
use axum::{
|
||||||
extract::{Path, State},
|
extract::{Path, State},
|
||||||
|
http::StatusCode,
|
||||||
Json,
|
Json,
|
||||||
};
|
};
|
||||||
use http::StatusCode;
|
|
||||||
use metrics::counter;
|
use metrics::counter;
|
||||||
use rand::rngs::OsRng;
|
use rand::rngs::OsRng;
|
||||||
use tracing::{debug, error, info, instrument};
|
use tracing::{debug, error, info, instrument};
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
use axum::{extract::Query, extract::State, Json};
|
use axum::{extract::Query, extract::State, http::StatusCode, Json};
|
||||||
use http::StatusCode;
|
|
||||||
use metrics::counter;
|
use metrics::counter;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use tracing::{error, instrument};
|
use tracing::{error, instrument};
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
#![forbid(unsafe_code)]
|
#![forbid(unsafe_code)]
|
||||||
|
|
||||||
|
use std::future::Future;
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::{future::Future, net::TcpListener};
|
|
||||||
|
|
||||||
use atuin_server_database::Database;
|
use atuin_server_database::Database;
|
||||||
use axum::Router;
|
use axum::{serve, Router};
|
||||||
use axum::Server;
|
|
||||||
use axum_server::Handle;
|
use axum_server::Handle;
|
||||||
use eyre::{Context, Result};
|
use eyre::{Context, Result};
|
||||||
|
|
||||||
@ -21,6 +20,7 @@ pub use settings::Settings;
|
|||||||
|
|
||||||
pub mod settings;
|
pub mod settings;
|
||||||
|
|
||||||
|
use tokio::net::TcpListener;
|
||||||
use tokio::signal;
|
use tokio::signal;
|
||||||
|
|
||||||
#[cfg(target_family = "unix")]
|
#[cfg(target_family = "unix")]
|
||||||
@ -55,7 +55,9 @@ pub async fn launch<Db: Database>(
|
|||||||
} else {
|
} else {
|
||||||
launch_with_tcp_listener::<Db>(
|
launch_with_tcp_listener::<Db>(
|
||||||
settings,
|
settings,
|
||||||
TcpListener::bind(addr).context("could not connect to socket")?,
|
TcpListener::bind(addr)
|
||||||
|
.await
|
||||||
|
.context("could not connect to socket")?,
|
||||||
shutdown_signal(),
|
shutdown_signal(),
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
@ -65,13 +67,11 @@ pub async fn launch<Db: Database>(
|
|||||||
pub async fn launch_with_tcp_listener<Db: Database>(
|
pub async fn launch_with_tcp_listener<Db: Database>(
|
||||||
settings: Settings<Db::Settings>,
|
settings: Settings<Db::Settings>,
|
||||||
listener: TcpListener,
|
listener: TcpListener,
|
||||||
shutdown: impl Future<Output = ()>,
|
shutdown: impl Future<Output = ()> + Send + 'static,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let r = make_router::<Db>(settings).await?;
|
let r = make_router::<Db>(settings).await?;
|
||||||
|
|
||||||
Server::from_tcp(listener)
|
serve(listener, r.into_make_service())
|
||||||
.context("could not launch server")?
|
|
||||||
.serve(r.into_make_service())
|
|
||||||
.with_graceful_shutdown(shutdown)
|
.with_graceful_shutdown(shutdown)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
@ -115,7 +115,9 @@ async fn launch_with_tls<Db: Database>(
|
|||||||
// The separate listener means it's much easier to ensure metrics are not accidentally exposed to
|
// The separate listener means it's much easier to ensure metrics are not accidentally exposed to
|
||||||
// the public.
|
// the public.
|
||||||
pub async fn launch_metrics_server(host: String, port: u16) -> Result<()> {
|
pub async fn launch_metrics_server(host: String, port: u16) -> Result<()> {
|
||||||
let listener = TcpListener::bind((host, port)).context("failed to bind metrics tcp")?;
|
let listener = TcpListener::bind((host, port))
|
||||||
|
.await
|
||||||
|
.context("failed to bind metrics tcp")?;
|
||||||
|
|
||||||
let recorder_handle = metrics::setup_metrics_recorder();
|
let recorder_handle = metrics::setup_metrics_recorder();
|
||||||
|
|
||||||
@ -124,9 +126,7 @@ pub async fn launch_metrics_server(host: String, port: u16) -> Result<()> {
|
|||||||
axum::routing::get(move || std::future::ready(recorder_handle.render())),
|
axum::routing::get(move || std::future::ready(recorder_handle.render())),
|
||||||
);
|
);
|
||||||
|
|
||||||
Server::from_tcp(listener)
|
serve(listener, router.into_make_service())
|
||||||
.context("could not launch server")?
|
|
||||||
.serve(router.into_make_service())
|
|
||||||
.with_graceful_shutdown(shutdown_signal())
|
.with_graceful_shutdown(shutdown_signal())
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
|
||||||
use axum::{extract::MatchedPath, http::Request, middleware::Next, response::IntoResponse};
|
use axum::{
|
||||||
|
extract::{MatchedPath, Request},
|
||||||
|
middleware::Next,
|
||||||
|
response::IntoResponse,
|
||||||
|
};
|
||||||
use metrics_exporter_prometheus::{Matcher, PrometheusBuilder, PrometheusHandle};
|
use metrics_exporter_prometheus::{Matcher, PrometheusBuilder, PrometheusHandle};
|
||||||
|
|
||||||
pub fn setup_metrics_recorder() -> PrometheusHandle {
|
pub fn setup_metrics_recorder() -> PrometheusHandle {
|
||||||
@ -21,7 +25,7 @@ pub fn setup_metrics_recorder() -> PrometheusHandle {
|
|||||||
/// Middleware to record some common HTTP metrics
|
/// Middleware to record some common HTTP metrics
|
||||||
/// Generic over B to allow for arbitrary body types (eg Vec<u8>, Streams, a deserialized thing, etc)
|
/// Generic over B to allow for arbitrary body types (eg Vec<u8>, Streams, a deserialized thing, etc)
|
||||||
/// Someday tower-http might provide a metrics middleware: https://github.com/tower-rs/tower-http/issues/57
|
/// Someday tower-http might provide a metrics middleware: https://github.com/tower-rs/tower-http/issues/57
|
||||||
pub async fn track_metrics<B>(req: Request<B>, next: Next<B>) -> impl IntoResponse {
|
pub async fn track_metrics(req: Request, next: Next) -> impl IntoResponse {
|
||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
|
|
||||||
let path = if let Some(matched_path) = req.extensions().get::<MatchedPath>() {
|
let path = if let Some(matched_path) = req.extensions().get::<MatchedPath>() {
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use atuin_common::api::{ErrorResponse, ATUIN_CARGO_VERSION, ATUIN_HEADER_VERSION};
|
use atuin_common::api::{ErrorResponse, ATUIN_CARGO_VERSION, ATUIN_HEADER_VERSION};
|
||||||
use axum::{
|
use axum::{
|
||||||
extract::FromRequestParts,
|
extract::{FromRequestParts, Request},
|
||||||
http::Request,
|
http::{self, request::Parts},
|
||||||
middleware::Next,
|
middleware::Next,
|
||||||
response::{IntoResponse, Response},
|
response::{IntoResponse, Response},
|
||||||
routing::{delete, get, post},
|
routing::{delete, get, post},
|
||||||
Router,
|
Router,
|
||||||
};
|
};
|
||||||
use eyre::Result;
|
use eyre::Result;
|
||||||
use http::request::Parts;
|
|
||||||
use tower::ServiceBuilder;
|
use tower::ServiceBuilder;
|
||||||
use tower_http::trace::TraceLayer;
|
use tower_http::trace::TraceLayer;
|
||||||
|
|
||||||
@ -81,7 +80,7 @@ async fn teapot() -> impl IntoResponse {
|
|||||||
(http::StatusCode::NOT_FOUND, "404 not found")
|
(http::StatusCode::NOT_FOUND, "404 not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn clacks_overhead<B>(request: Request<B>, next: Next<B>) -> Response {
|
async fn clacks_overhead(request: Request, next: Next) -> Response {
|
||||||
let mut response = next.run(request).await;
|
let mut response = next.run(request).await;
|
||||||
|
|
||||||
let gnu_terry_value = "GNU Terry Pratchett, Kris Nova";
|
let gnu_terry_value = "GNU Terry Pratchett, Kris Nova";
|
||||||
@ -94,7 +93,7 @@ async fn clacks_overhead<B>(request: Request<B>, next: Next<B>) -> Response {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Ensure that we only try and sync with clients on the same major version
|
/// Ensure that we only try and sync with clients on the same major version
|
||||||
async fn semver<B>(request: Request<B>, next: Next<B>) -> Response {
|
async fn semver(request: Request, next: Next) -> Response {
|
||||||
let mut response = next.run(request).await;
|
let mut response = next.run(request).await;
|
||||||
response
|
response
|
||||||
.headers_mut()
|
.headers_mut()
|
||||||
|
@ -116,10 +116,9 @@ impl Tls {
|
|||||||
.with_context(|| format!("tls.cert_path {:?} is missing", self.cert_path))?;
|
.with_context(|| format!("tls.cert_path {:?} is missing", self.cert_path))?;
|
||||||
let mut reader = std::io::BufReader::new(cert_file);
|
let mut reader = std::io::BufReader::new(cert_file);
|
||||||
let certs: Vec<_> = rustls_pemfile::certs(&mut reader)
|
let certs: Vec<_> = rustls_pemfile::certs(&mut reader)
|
||||||
.with_context(|| format!("tls.cert_path {:?} is invalid", self.cert_path))?
|
.map(|c| c.map(|c| rustls::Certificate(c.to_vec())))
|
||||||
.into_iter()
|
.collect::<Result<Vec<_>, _>>()
|
||||||
.map(rustls::Certificate)
|
.with_context(|| format!("tls.cert_path {:?} is invalid", self.cert_path))?;
|
||||||
.collect();
|
|
||||||
|
|
||||||
if certs.is_empty() {
|
if certs.is_empty() {
|
||||||
bail!(
|
bail!(
|
||||||
@ -136,6 +135,8 @@ impl Tls {
|
|||||||
.with_context(|| format!("tls.pkey_path {:?} is missing", self.pkey_path))?;
|
.with_context(|| format!("tls.pkey_path {:?} is missing", self.pkey_path))?;
|
||||||
let mut reader = std::io::BufReader::new(pkey_file);
|
let mut reader = std::io::BufReader::new(pkey_file);
|
||||||
let keys = rustls_pemfile::pkcs8_private_keys(&mut reader)
|
let keys = rustls_pemfile::pkcs8_private_keys(&mut reader)
|
||||||
|
.map(|c| c.map(|c| rustls::PrivateKey(c.secret_pkcs8_der().to_vec())))
|
||||||
|
.collect::<Result<Vec<_>, _>>()
|
||||||
.with_context(|| format!("tls.pkey_path {:?} is not PKCS8-encoded", self.pkey_path))?;
|
.with_context(|| format!("tls.pkey_path {:?} is not PKCS8-encoded", self.pkey_path))?;
|
||||||
|
|
||||||
if keys.is_empty() {
|
if keys.is_empty() {
|
||||||
@ -145,8 +146,6 @@ impl Tls {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let key = rustls::PrivateKey(keys[0].clone());
|
Ok(keys[0].clone())
|
||||||
|
|
||||||
Ok(key)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use std::{env, net::TcpListener, time::Duration};
|
use std::{env, time::Duration};
|
||||||
|
|
||||||
use atuin_client::api_client;
|
use atuin_client::api_client;
|
||||||
use atuin_common::{api::AddHistoryRequest, utils::uuid_v7};
|
use atuin_common::{api::AddHistoryRequest, utils::uuid_v7};
|
||||||
@ -6,7 +6,7 @@ use atuin_server::{launch_with_tcp_listener, Settings as ServerSettings};
|
|||||||
use atuin_server_postgres::{Postgres, PostgresSettings};
|
use atuin_server_postgres::{Postgres, PostgresSettings};
|
||||||
use futures_util::TryFutureExt;
|
use futures_util::TryFutureExt;
|
||||||
use time::OffsetDateTime;
|
use time::OffsetDateTime;
|
||||||
use tokio::{sync::oneshot, task::JoinHandle};
|
use tokio::{net::TcpListener, sync::oneshot, task::JoinHandle};
|
||||||
use tracing::{dispatcher, Dispatch};
|
use tracing::{dispatcher, Dispatch};
|
||||||
use tracing_subscriber::{layer::SubscriberExt, EnvFilter};
|
use tracing_subscriber::{layer::SubscriberExt, EnvFilter};
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ async fn start_server(path: &str) -> (String, oneshot::Sender<()>, JoinHandle<()
|
|||||||
};
|
};
|
||||||
|
|
||||||
let (shutdown_tx, shutdown_rx) = tokio::sync::oneshot::channel();
|
let (shutdown_tx, shutdown_rx) = tokio::sync::oneshot::channel();
|
||||||
let listener = TcpListener::bind("127.0.0.1:0").unwrap();
|
let listener = TcpListener::bind("127.0.0.1:0").await.unwrap();
|
||||||
let addr = listener.local_addr().unwrap();
|
let addr = listener.local_addr().unwrap();
|
||||||
let server = tokio::spawn(async move {
|
let server = tokio::spawn(async move {
|
||||||
let _tracing_guard = dispatcher::set_default(&dispatch);
|
let _tracing_guard = dispatcher::set_default(&dispatch);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user