add content-type octet stream helper fn (#5062)

This commit is contained in:
Eitan Seri-Levi
2024-01-15 07:23:39 +02:00
committed by GitHub
parent 00af017582
commit 72bcf47dd0
4 changed files with 32 additions and 22 deletions

View File

@@ -1,7 +1,7 @@
use crate::api_types::EndpointVersion;
use eth2::{
CONSENSUS_BLOCK_VALUE_HEADER, CONSENSUS_VERSION_HEADER, EXECUTION_PAYLOAD_BLINDED_HEADER,
EXECUTION_PAYLOAD_VALUE_HEADER,
CONSENSUS_BLOCK_VALUE_HEADER, CONSENSUS_VERSION_HEADER, CONTENT_TYPE_HEADER,
EXECUTION_PAYLOAD_BLINDED_HEADER, EXECUTION_PAYLOAD_VALUE_HEADER, SSZ_CONTENT_TYPE_HEADER,
};
use serde::Serialize;
use types::{
@@ -59,6 +59,11 @@ pub fn execution_optimistic_finalized_fork_versioned_response<T: Serialize>(
})
}
/// Add the 'Content-Type application/octet-stream` header to a response.
pub fn add_ssz_content_type_header<T: Reply>(reply: T) -> Response {
reply::with_header(reply, CONTENT_TYPE_HEADER, SSZ_CONTENT_TYPE_HEADER).into_response()
}
/// Add the `Eth-Consensus-Version` header to a response.
pub fn add_consensus_version_header<T: Reply>(reply: T, fork_name: ForkName) -> Response {
reply::with_header(reply, CONSENSUS_VERSION_HEADER, fork_name.to_string()).into_response()