Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
use crate::http_server::routes::middlewares;
use crate::DependencyContainer;
use std::sync::Arc;
use warp::Filter;

pub fn routes(
dependency_manager: Arc<DependencyContainer>,
dependency_manager: &DependencyContainer,
) -> impl Filter<Extract = (impl warp::Reply,), Error = warp::Rejection> + Clone {
artifact_cardano_stake_distributions(dependency_manager.clone())
artifact_cardano_stake_distributions(dependency_manager)
.or(artifact_cardano_stake_distribution_by_id(
dependency_manager.clone(),
dependency_manager,
))
.or(artifact_cardano_stake_distribution_by_epoch(
dependency_manager,
Expand All @@ -17,7 +16,7 @@ pub fn routes(

/// GET /artifact/cardano-stake-distributions
fn artifact_cardano_stake_distributions(
dependency_manager: Arc<DependencyContainer>,
dependency_manager: &DependencyContainer,
) -> impl Filter<Extract = (impl warp::Reply,), Error = warp::Rejection> + Clone {
warp::path!("artifact" / "cardano-stake-distributions")
.and(warp::get())
Expand All @@ -27,7 +26,7 @@ fn artifact_cardano_stake_distributions(

/// GET /artifact/cardano-stake-distribution/:id
fn artifact_cardano_stake_distribution_by_id(
dependency_manager: Arc<DependencyContainer>,
dependency_manager: &DependencyContainer,
) -> impl Filter<Extract = (impl warp::Reply,), Error = warp::Rejection> + Clone {
warp::path!("artifact" / "cardano-stake-distribution" / String)
.and(warp::get())
Expand All @@ -37,7 +36,7 @@ fn artifact_cardano_stake_distribution_by_id(

/// GET /artifact/cardano-stake-distribution/epoch/:epoch
fn artifact_cardano_stake_distribution_by_epoch(
dependency_manager: Arc<DependencyContainer>,
dependency_manager: &DependencyContainer,
) -> impl Filter<Extract = (impl warp::Reply,), Error = warp::Rejection> + Clone {
warp::path!("artifact" / "cardano-stake-distribution" / "epoch" / String)
.and(warp::get())
Expand Down Expand Up @@ -137,6 +136,7 @@ pub mod handlers {
pub mod tests {
use anyhow::anyhow;
use serde_json::Value::Null;
use std::sync::Arc;
use warp::{
http::{Method, StatusCode},
test::request,
Expand All @@ -163,7 +163,7 @@ pub mod tests {

warp::any()
.and(warp::path(SERVER_BASE_PATH))
.and(routes(dependency_manager).with(cors))
.and(routes(&dependency_manager).with(cors))
}

#[tokio::test]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
use crate::http_server::routes::middlewares;
use crate::DependencyContainer;
use std::sync::Arc;
use warp::Filter;

pub fn routes(
dependency_manager: Arc<DependencyContainer>,
dependency_manager: &DependencyContainer,
) -> impl Filter<Extract = (impl warp::Reply,), Error = warp::Rejection> + Clone {
artifact_cardano_transactions(dependency_manager.clone())
artifact_cardano_transactions(dependency_manager)
.or(artifact_cardano_transaction_by_id(dependency_manager))
}

/// GET /artifact/cardano-transactions
fn artifact_cardano_transactions(
dependency_manager: Arc<DependencyContainer>,
dependency_manager: &DependencyContainer,
) -> impl Filter<Extract = (impl warp::Reply,), Error = warp::Rejection> + Clone {
warp::path!("artifact" / "cardano-transactions")
.and(warp::get())
Expand All @@ -22,7 +21,7 @@ fn artifact_cardano_transactions(

/// GET /artifact/cardano-transaction/:id
fn artifact_cardano_transaction_by_id(
dependency_manager: Arc<DependencyContainer>,
dependency_manager: &DependencyContainer,
) -> impl Filter<Extract = (impl warp::Reply,), Error = warp::Rejection> + Clone {
warp::path!("artifact" / "cardano-transaction" / String)
.and(warp::get())
Expand Down Expand Up @@ -102,6 +101,7 @@ pub mod tests {
};
use mithril_persistence::sqlite::HydrationError;
use serde_json::Value::Null;
use std::sync::Arc;
use warp::{
http::{Method, StatusCode},
test::request,
Expand All @@ -119,7 +119,7 @@ pub mod tests {

warp::any()
.and(warp::path(SERVER_BASE_PATH))
.and(routes(dependency_manager).with(cors))
.and(routes(&dependency_manager).with(cors))
}

#[tokio::test]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
use crate::http_server::routes::middlewares;
use crate::DependencyContainer;
use std::sync::Arc;
use warp::Filter;

pub fn routes(
dependency_manager: Arc<DependencyContainer>,
dependency_manager: &DependencyContainer,
) -> impl Filter<Extract = (impl warp::Reply,), Error = warp::Rejection> + Clone {
artifact_mithril_stake_distributions(dependency_manager.clone()).or(
artifact_mithril_stake_distributions(dependency_manager).or(
artifact_mithril_stake_distribution_by_id(dependency_manager),
)
}

/// GET /artifact/mithril-stake-distributions
fn artifact_mithril_stake_distributions(
dependency_manager: Arc<DependencyContainer>,
dependency_manager: &DependencyContainer,
) -> impl Filter<Extract = (impl warp::Reply,), Error = warp::Rejection> + Clone {
warp::path!("artifact" / "mithril-stake-distributions")
.and(warp::get())
Expand All @@ -23,7 +22,7 @@ fn artifact_mithril_stake_distributions(

/// GET /artifact/mithril-stake-distribution/:id
fn artifact_mithril_stake_distribution_by_id(
dependency_manager: Arc<DependencyContainer>,
dependency_manager: &DependencyContainer,
) -> impl Filter<Extract = (impl warp::Reply,), Error = warp::Rejection> + Clone {
warp::path!("artifact" / "mithril-stake-distribution" / String)
.and(warp::get())
Expand Down Expand Up @@ -102,6 +101,7 @@ pub mod tests {
};
use mithril_persistence::sqlite::HydrationError;
use serde_json::Value::Null;
use std::sync::Arc;
use warp::{
http::{Method, StatusCode},
test::request,
Expand All @@ -119,7 +119,7 @@ pub mod tests {

warp::any()
.and(warp::path(SERVER_BASE_PATH))
.and(routes(dependency_manager).with(cors))
.and(routes(&dependency_manager).with(cors))
}

#[tokio::test]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
use crate::http_server::routes::middlewares;
use crate::http_server::SERVER_BASE_PATH;
use crate::DependencyContainer;
use std::sync::Arc;
use warp::hyper::Uri;
use warp::Filter;

pub fn routes(
dependency_manager: Arc<DependencyContainer>,
dependency_manager: &DependencyContainer,
) -> impl Filter<Extract = (impl warp::Reply,), Error = warp::Rejection> + Clone {
artifact_cardano_full_immutable_snapshots(dependency_manager.clone())
artifact_cardano_full_immutable_snapshots(dependency_manager)
.or(artifact_cardano_full_immutable_snapshot_by_id(
dependency_manager.clone(),
dependency_manager,
))
.or(serve_snapshots_dir(dependency_manager.clone()))
.or(serve_snapshots_dir(dependency_manager))
.or(snapshot_download(dependency_manager))
.or(artifact_cardano_full_immutable_snapshots_legacy())
.or(artifact_cardano_full_immutable_snapshot_by_id_legacy())
}

/// GET /artifact/snapshots
fn artifact_cardano_full_immutable_snapshots(
dependency_manager: Arc<DependencyContainer>,
dependency_manager: &DependencyContainer,
) -> impl Filter<Extract = (impl warp::Reply,), Error = warp::Rejection> + Clone {
warp::path!("artifact" / "snapshots")
.and(warp::get())
Expand All @@ -30,7 +29,7 @@ fn artifact_cardano_full_immutable_snapshots(

/// GET /artifact/snapshot/:id
fn artifact_cardano_full_immutable_snapshot_by_id(
dependency_manager: Arc<DependencyContainer>,
dependency_manager: &DependencyContainer,
) -> impl Filter<Extract = (impl warp::Reply,), Error = warp::Rejection> + Clone {
warp::path!("artifact" / "snapshot" / String)
.and(warp::get())
Expand All @@ -40,17 +39,17 @@ fn artifact_cardano_full_immutable_snapshot_by_id(

/// GET /artifact/snapshots/{digest}/download
fn snapshot_download(
dependency_manager: Arc<DependencyContainer>,
dependency_manager: &DependencyContainer,
) -> impl Filter<Extract = (impl warp::Reply,), Error = warp::Rejection> + Clone {
warp::path!("artifact" / "snapshot" / String / "download")
.and(warp::get().or(warp::head()).unify())
.and(middlewares::with_config(dependency_manager.clone()))
.and(middlewares::with_config(dependency_manager))
.and(middlewares::with_signed_entity_service(dependency_manager))
.and_then(handlers::snapshot_download)
}

fn serve_snapshots_dir(
dependency_manager: Arc<DependencyContainer>,
dependency_manager: &DependencyContainer,
) -> impl Filter<Extract = (impl warp::Reply,), Error = warp::Rejection> + Clone {
let config = dependency_manager.config.clone();

Expand Down Expand Up @@ -234,6 +233,7 @@ mod tests {
};
use mithril_persistence::sqlite::HydrationError;
use serde_json::Value::Null;
use std::sync::Arc;
use warp::{
http::{Method, StatusCode},
test::request,
Expand All @@ -251,7 +251,7 @@ mod tests {

warp::any()
.and(warp::path(SERVER_BASE_PATH))
.and(routes(dependency_manager).with(cors))
.and(routes(&dependency_manager).with(cors))
}

#[tokio::test]
Expand Down
16 changes: 8 additions & 8 deletions mithril-aggregator/src/http_server/routes/certificate_routes.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
use crate::http_server::routes::middlewares;
use crate::DependencyContainer;
use std::sync::Arc;
use warp::Filter;

pub fn routes(
dependency_manager: Arc<DependencyContainer>,
dependency_manager: &DependencyContainer,
) -> impl Filter<Extract = (impl warp::Reply,), Error = warp::Rejection> + Clone {
certificate_pending(dependency_manager.clone())
.or(certificate_certificates(dependency_manager.clone()))
certificate_pending(dependency_manager)
.or(certificate_certificates(dependency_manager))
.or(certificate_certificate_hash(dependency_manager))
}

/// GET /certificate-pending
fn certificate_pending(
dependency_manager: Arc<DependencyContainer>,
dependency_manager: &DependencyContainer,
) -> impl Filter<Extract = (impl warp::Reply,), Error = warp::Rejection> + Clone {
warp::path!("certificate-pending")
.and(warp::get())
Expand All @@ -25,7 +24,7 @@ fn certificate_pending(

/// GET /certificates
fn certificate_certificates(
dependency_manager: Arc<DependencyContainer>,
dependency_manager: &DependencyContainer,
) -> impl Filter<Extract = (impl warp::Reply,), Error = warp::Rejection> + Clone {
warp::path!("certificates")
.and(warp::get())
Expand All @@ -35,7 +34,7 @@ fn certificate_certificates(

/// GET /certificate/{certificate_hash}
fn certificate_certificate_hash(
dependency_manager: Arc<DependencyContainer>,
dependency_manager: &DependencyContainer,
) -> impl Filter<Extract = (impl warp::Reply,), Error = warp::Rejection> + Clone {
warp::path!("certificate" / String)
.and(warp::get())
Expand Down Expand Up @@ -126,6 +125,7 @@ mod tests {
};
use mithril_persistence::store::adapter::DumbStoreAdapter;
use serde_json::Value::Null;
use std::sync::Arc;
use warp::{
http::{Method, StatusCode},
test::request,
Expand All @@ -148,7 +148,7 @@ mod tests {

warp::any()
.and(warp::path(SERVER_BASE_PATH))
.and(routes(dependency_manager).with(cors))
.and(routes(&dependency_manager).with(cors))
}

#[tokio::test]
Expand Down
11 changes: 6 additions & 5 deletions mithril-aggregator/src/http_server/routes/epoch_routes.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{collections::BTreeSet, sync::Arc};
use std::collections::BTreeSet;
use warp::Filter;

use mithril_common::{
Expand All @@ -12,18 +12,18 @@ use crate::http_server::routes::middlewares;
use crate::DependencyContainer;

pub fn routes(
dependency_manager: Arc<DependencyContainer>,
dependency_manager: &DependencyContainer,
) -> impl Filter<Extract = (impl warp::Reply,), Error = warp::Rejection> + Clone {
epoch_settings(dependency_manager)
}

/// GET /epoch-settings
fn epoch_settings(
dependency_manager: Arc<DependencyContainer>,
dependency_manager: &DependencyContainer,
) -> impl Filter<Extract = (impl warp::Reply,), Error = warp::Rejection> + Clone {
warp::path!("epoch-settings")
.and(warp::get())
.and(middlewares::with_epoch_service(dependency_manager.clone()))
.and(middlewares::with_epoch_service(dependency_manager))
.and(middlewares::with_allowed_signed_entity_type_discriminants(
dependency_manager,
))
Expand Down Expand Up @@ -99,6 +99,7 @@ mod handlers {
mod tests {
use serde_json::Value::Null;
use std::collections::BTreeSet;
use std::sync::Arc;
use tokio::sync::RwLock;
use warp::{
http::{Method, StatusCode},
Expand Down Expand Up @@ -129,7 +130,7 @@ mod tests {

warp::any()
.and(warp::path(SERVER_BASE_PATH))
.and(routes(dependency_manager).with(cors))
.and(routes(&dependency_manager).with(cors))
}

#[tokio::test]
Expand Down
Loading
Loading