Skip to content

Commit f08a53c

Browse files
authored
Merge pull request #926 from input-output-hk/jpraynaud/893-fix-legacy-snapshot-route-urls
Fix legacy snapshot routes redirect
2 parents 0874697 + 96bff33 commit f08a53c

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mithril-aggregator/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mithril-aggregator"
3-
version = "0.3.19"
3+
version = "0.3.20"
44
description = "A Mithril Aggregator server"
55
authors = { workspace = true }
66
edition = { workspace = true }

mithril-aggregator/src/http_server/routes/artifact_routes/snapshot.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
use super::shared;
2+
use crate::http_server::SERVER_BASE_PATH;
23
use crate::message_adapters::ToSnapshotMessageAdapter;
34
use crate::DependencyManager;
45
use crate::{http_server::routes::middlewares, message_adapters::ToSnapshotListMessageAdapter};
56
use mithril_common::entities::{Beacon, SignedEntityType, Snapshot};
67
use mithril_common::messages::{SnapshotListMessage, SnapshotMessage};
78
use std::sync::Arc;
9+
use warp::hyper::Uri;
810
use warp::Filter;
911

1012
pub fn routes(
@@ -16,6 +18,8 @@ pub fn routes(
1618
))
1719
.or(serve_snapshots_dir(dependency_manager.clone()))
1820
.or(snapshot_download(dependency_manager))
21+
.or(artifact_cardano_full_immutable_snapshots_legacy())
22+
.or(artifact_cardano_full_immutable_snapshot_by_id_legacy())
1923
}
2024

2125
/// GET /artifact/snapshots
@@ -75,6 +79,34 @@ fn serve_snapshots_dir(
7579
.and_then(handlers::ensure_downloaded_file_is_a_snapshot)
7680
}
7781

82+
/// GET /snapshots
83+
// TODO: This legacy route should be removed when this code is released with a new distribution
84+
fn artifact_cardano_full_immutable_snapshots_legacy(
85+
) -> impl Filter<Extract = (impl warp::Reply,), Error = warp::Rejection> + Clone {
86+
warp::path!("snapshots").map(|| {
87+
warp::redirect(
88+
format!("/{SERVER_BASE_PATH}/artifact/snapshots")
89+
.as_str()
90+
.parse::<Uri>()
91+
.unwrap(),
92+
)
93+
})
94+
}
95+
96+
/// GET /snapshot/digest
97+
// TODO: This legacy route should be removed when this code is released with a new distribution
98+
fn artifact_cardano_full_immutable_snapshot_by_id_legacy(
99+
) -> impl Filter<Extract = (impl warp::Reply,), Error = warp::Rejection> + Clone {
100+
warp::path!("snapshot" / String).map(|digest| {
101+
warp::redirect(
102+
format!("/{SERVER_BASE_PATH}/artifact/snapshot/{digest}")
103+
.as_str()
104+
.parse::<Uri>()
105+
.unwrap(),
106+
)
107+
})
108+
}
109+
78110
mod handlers {
79111
use crate::database::provider::SignedEntityStorer;
80112
use crate::http_server::routes::reply;

0 commit comments

Comments
 (0)