use http::HeaderMap;

/// Context passed to every action invocation.
///
/// Carries the request headers and the active tracing span. For direct
/// (non-HTTP) invocations from SSR paths, construct via `ActionContext::synthetic()`.
#[derive(Clone)]
pub struct ActionContext {
    pub headers: HeaderMap,
    pub span: tracing::Span,
}

impl ActionContext {
    pub fn new(headers: HeaderMap) -> Self {
        Self {
            headers,
            span: tracing::Span::current(),
        }
    }

    /// Synthetic context for direct (non-HTTP) calls, e.g. from streaming SSR.
    pub fn synthetic() -> Self {
        Self {
            headers: HeaderMap::new(),
            span: tracing::Span::current(),
        }
    }
}
