Skip to content

Commit 99b1d67

Browse files
committed
add API version in HTTP headers
1 parent 927c6df commit 99b1d67

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

mithril-aggregator/src/http_server/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ mod routes;
22
mod server;
33

44
pub use server::{Server, SERVER_BASE_PATH};
5+
6+
pub const MITHRIL_API_VERSION: &str = "0.1.0";

mithril-aggregator/src/http_server/routes/router.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
use crate::http_server::routes::{
22
certificate_routes, epoch_routes, signatures_routes, signer_routes, snapshot_routes,
33
};
4-
use crate::http_server::SERVER_BASE_PATH;
4+
use crate::http_server::{MITHRIL_API_VERSION, SERVER_BASE_PATH};
55
use crate::DependencyManager;
6+
use reqwest::header::{HeaderMap, HeaderValue};
67
use std::sync::Arc;
78
use warp::http::Method;
89
use warp::Filter;
@@ -15,13 +16,19 @@ pub fn routes(
1516
.allow_any_origin()
1617
.allow_headers(vec!["content-type"])
1718
.allow_methods(vec![Method::GET, Method::POST, Method::OPTIONS]);
19+
let mut headers = HeaderMap::new();
20+
headers.insert(
21+
"mithril-api-version",
22+
HeaderValue::from_static(MITHRIL_API_VERSION),
23+
);
1824

1925
warp::any().and(warp::path(SERVER_BASE_PATH)).and(
2026
certificate_routes::routes(dependency_manager.clone())
2127
.or(snapshot_routes::routes(dependency_manager.clone()))
2228
.or(signer_routes::routes(dependency_manager.clone()))
2329
.or(signatures_routes::routes(dependency_manager.clone()))
2430
.or(epoch_routes::routes(dependency_manager))
25-
.with(cors),
31+
.with(cors)
32+
.with(warp::reply::with::headers(headers)),
2633
)
2734
}

0 commit comments

Comments
 (0)