Move routerify behind zenith_utils

This commit is contained in:
Kirill Bulatov
2022-02-09 00:29:30 +02:00
committed by Kirill Bulatov
parent c5b5905ed3
commit 6eef401602
10 changed files with 6 additions and 16 deletions

3
Cargo.lock generated
View File

@@ -1290,7 +1290,6 @@ dependencies = [
"postgres_ffi",
"rand",
"regex",
"routerify",
"rust-s3",
"scopeguard",
"serde",
@@ -1563,7 +1562,6 @@ dependencies = [
"md5",
"rand",
"reqwest",
"routerify",
"rustls 0.19.1",
"serde",
"serde_json",
@@ -2509,7 +2507,6 @@ dependencies = [
"postgres-protocol 0.6.1 (git+https://github.com/zenithdb/rust-postgres.git?rev=2949d98df52587d562986aad155dd4e889e408b7)",
"postgres_ffi",
"regex",
"routerify",
"rust-s3",
"serde",
"serde_json",

View File

@@ -22,7 +22,6 @@ postgres-protocol = { git = "https://github.com/zenithdb/rust-postgres.git", rev
postgres = { git = "https://github.com/zenithdb/rust-postgres.git", rev="2949d98df52587d562986aad155dd4e889e408b7" }
tokio-postgres = { git = "https://github.com/zenithdb/rust-postgres.git", rev="2949d98df52587d562986aad155dd4e889e408b7" }
tokio-stream = "0.1.8"
routerify = "3"
anyhow = { version = "1.0", features = ["backtrace"] }
crc32c = "0.6.0"
thiserror = "1.0"

View File

@@ -4,7 +4,6 @@ use anyhow::{Context, Result};
use hyper::header;
use hyper::StatusCode;
use hyper::{Body, Request, Response, Uri};
use routerify::{ext::RequestExt, RouterBuilder};
use serde::Serialize;
use tracing::*;
use zenith_utils::auth::JwtAuth;
@@ -19,6 +18,7 @@ use zenith_utils::http::{
request::get_request_param,
request::parse_request_param,
};
use zenith_utils::http::{RequestExt, RouterBuilder};
use zenith_utils::lsn::Lsn;
use zenith_utils::zid::{opt_display_serde, ZTimelineId};

View File

@@ -334,8 +334,7 @@ impl VirtualFile {
// library RwLock doesn't allow downgrading without releasing the lock,
// and that doesn't seem worth the trouble.
//
// XXX
// `parking_lot::RwLock` can enable such downgrades, yet its implemenation is fair and
// XXX `parking_lot::RwLock` can enable such downgrades, yet its implemenation is fair and
// may deadlock on subsequent read calls, not all code places would benefit from such benaviour
let result = STORAGE_IO_TIME
.with_label_values(&[op, &self.tenantid, &self.timelineid])

View File

@@ -11,8 +11,6 @@ md5 = "0.7.0"
rand = "0.8.3"
hex = "0.4.3"
hyper = "0.14"
# TODO kb reexport this from zenith_utils
routerify = "3"
serde = "1"
serde_json = "1"
tokio = { version = "1.11", features = ["macros"] }

View File

@@ -1,5 +1,5 @@
use hyper::{Body, Request, Response, StatusCode};
use routerify::RouterBuilder;
use zenith_utils::http::RouterBuilder;
use zenith_utils::http::endpoint;
use zenith_utils::http::error::ApiError;

View File

@@ -8,7 +8,6 @@ regex = "1.4.5"
bytes = "1.0.1"
byteorder = "1.4.3"
hyper = "0.14"
routerify = "3"
fs2 = "0.4.3"
lazy_static = "1.4.0"
serde_json = "1"

View File

@@ -1,10 +1,9 @@
use hyper::{Body, Request, Response, StatusCode};
use routerify::ext::RequestExt;
use routerify::RouterBuilder;
use serde::Serialize;
use serde::Serializer;
use std::fmt::Display;
use std::sync::Arc;
use zenith_utils::http::{RequestExt, RouterBuilder};
use zenith_utils::lsn::Lsn;
use zenith_utils::zid::ZTenantTimelineId;

View File

@@ -416,7 +416,7 @@ fn handle_init(init_match: &ArgMatches) -> Result<()> {
Ok(())
}
fn pageserver_config_overrides<'a>(init_match: &'a ArgMatches) -> Vec<&'a str> {
fn pageserver_config_overrides(init_match: &ArgMatches) -> Vec<&str> {
init_match
.values_of("pageserver-config-override")
.into_iter()

View File

@@ -110,7 +110,6 @@ fn parse_token(header_value: &str) -> Result<&str, ApiError> {
Ok(token)
}
// TODO kb now test_auth fails, is it after jsonwebtoken update?
pub fn auth_middleware<B: hyper::body::HttpBody + Send + Sync + 'static>(
provide_auth: fn(&Request<Body>) -> Option<&JwtAuth>,
) -> Middleware<B, ApiError> {
@@ -124,7 +123,7 @@ pub fn auth_middleware<B: hyper::body::HttpBody + Send + Sync + 'static>(
let token = parse_token(header_value)?;
let data = auth
.decode(dbg!(token))
.decode(token)
.map_err(|_| ApiError::Unauthorized("malformed jwt token".to_string()))?;
req.set_context(data.claims);
}