Skip to content

Commit

Permalink
feat: build header for path from config
Browse files Browse the repository at this point in the history
Signed-off-by: David Dal Busco <[email protected]>
  • Loading branch information
peterpeterparker committed Nov 9, 2023
1 parent 5264273 commit 69de093
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/satellite/src/storage/http/headers.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use crate::storage::constants::ASSET_ENCODING_NO_COMPRESSION;
use crate::storage::http::types::HeaderField;
use crate::storage::types::config::StorageConfig;
use crate::storage::types::store::{Asset, AssetEncoding, EncodingType};
use crate::storage::url::matching_urls;
use hex::encode;

pub fn build_asset_headers(
Expand Down Expand Up @@ -62,3 +64,15 @@ fn security_headers() -> Vec<HeaderField> {
HeaderField("Referrer-Policy".to_string(), "same-origin".to_string()),
]
}

pub fn build_config_headers(
requested_path: &str,
StorageConfig {
headers: config_headers,
..
}: &StorageConfig,
) -> Vec<HeaderField> {
matching_urls(requested_path, config_headers).iter()
.flat_map(|(_, headers)| headers.clone())
.collect()
}

0 comments on commit 69de093

Please sign in to comment.