1
1
use super :: shared;
2
+ use crate :: http_server:: SERVER_BASE_PATH ;
2
3
use crate :: message_adapters:: ToSnapshotMessageAdapter ;
3
4
use crate :: DependencyManager ;
4
5
use crate :: { http_server:: routes:: middlewares, message_adapters:: ToSnapshotListMessageAdapter } ;
5
6
use mithril_common:: entities:: { Beacon , SignedEntityType , Snapshot } ;
6
7
use mithril_common:: messages:: { SnapshotListMessage , SnapshotMessage } ;
7
8
use std:: sync:: Arc ;
9
+ use warp:: hyper:: Uri ;
8
10
use warp:: Filter ;
9
11
10
12
pub fn routes (
@@ -16,6 +18,8 @@ pub fn routes(
16
18
) )
17
19
. or ( serve_snapshots_dir ( dependency_manager. clone ( ) ) )
18
20
. or ( snapshot_download ( dependency_manager) )
21
+ . or ( artifact_cardano_full_immutable_snapshots_legacy ( ) )
22
+ . or ( artifact_cardano_full_immutable_snapshot_by_id_legacy ( ) )
19
23
}
20
24
21
25
/// GET /artifact/snapshots
@@ -75,6 +79,34 @@ fn serve_snapshots_dir(
75
79
. and_then ( handlers:: ensure_downloaded_file_is_a_snapshot)
76
80
}
77
81
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
+
78
110
mod handlers {
79
111
use crate :: database:: provider:: SignedEntityStorer ;
80
112
use crate :: http_server:: routes:: reply;
0 commit comments