launchdarkly_server_sdk/fdv2/
request_headers.rs1#[derive(Clone)]
3pub struct RequestHeaders {
4 headers: Vec<(&'static str, String)>,
5}
6
7impl RequestHeaders {
8 pub(crate) fn new(sdk_key: &str, tags: Option<&str>, instance_id: &str) -> Self {
9 let mut headers = vec![
10 ("Authorization", sdk_key.to_string()),
11 ("User-Agent", crate::USER_AGENT.clone()),
12 (
13 crate::LAUNCHDARKLY_INSTANCE_ID_HEADER,
14 instance_id.to_string(),
15 ),
16 ];
17 if let Some(tags) = tags {
18 headers.push((crate::LAUNCHDARKLY_TAGS_HEADER, tags.to_string()));
19 }
20 Self { headers }
21 }
22
23 pub fn iter(&self) -> impl Iterator<Item = (&'static str, &str)> + '_ {
25 self.headers
26 .iter()
27 .map(|(name, value)| (*name, value.as_str()))
28 }
29}