pub fn insert_http_header(
        &self,
        name: impl IntoHeaderName,
        value: impl Into<String>,
    ) -> Option<String> {
        self.query_env
            .http_headers
            .lock()
            .unwrap()
            .insert(name, value.into())
    }
/// Sets a HTTP header to response.
///
/// If the header was not currently set on the response, then `None` is returned.
///
/// If the response already contained this header then the new value is associated with this key
/// and __all the previous values are removed__, however only a the first previous
/// value is returned.
///
/// See [`http::HeaderMap`] for more details on the underlying implementation
///
/// # Examples
///
/// ```no_run
/// use async_graphql::*;
/// use ::http::header::ACCESS_CONTROL_ALLOW_ORIGIN;
///
/// struct Query;
///
/// #[Object]
/// impl Query {
///     async fn greet(&self, ctx: &Context<'_>) -> String {
///
///         // Headers can be inserted using the `http` constants
///         let was_in_headers = ctx.insert_http_header(ACCESS_CONTROL_ALLOW_ORIGIN, "*");
///         assert_eq!(was_in_headers, None);
///
///         // They can also be inserted using &str
///         let was_in_headers = ctx.insert_http_header("Custom-Header", "1234");
///         assert_eq!(was_in_headers, None);
///
///         // If multiple headers with the same key are `inserted` then the most recent
///         // one overwrites the previous. If you want multiple headers for the same key, use
///         // `append_http_header` for subsequent headers
///         let was_in_headers = ctx.insert_http_header("Custom-Header", "Hello World");
///         assert_eq!(was_in_headers, Some("1234".to_string()));
///
///         String::from("Hello world")
///     }
/// }
/// ```
Sets a HTTP header to response.
If the header was not currently set on the response, then `None` is returned.

If the response already contained this header then the new value is associated with this key
and __all the previous values are removed__, however only a the first previous
value is returned.

See [`http::HeaderMap`] for more details on the underlying implementation
Sets a HTTP header to response . If the header was not currently set on the response then ` None ` is returned . If the response already contained this header then the new value is associated with this key and __all the previous values are removed__ however only a the first previous value is returned . See [ ` http :: HeaderMap ` ] for more details on the underlying implementation
pub fn insert_http_header(
        &self,
        name: impl IntoHeaderName,
        value: impl Into<String>,
    ) -> Option<String> {
        self.query_env
            .http_headers
            .lock()
            .unwrap()
            .insert(name, value.into())
    }
pub fn insert_http_header ( & self , name : impl IntoHeaderName , value : impl Into < String > , ) -> Option < String > { self . query_env . http_headers . lock ( ) . unwrap ( ) . insert ( name , value . into ( ) ) }
Sets a HTTP header to response.
Sets a HTTP header to response .
&self
name
impl IntoHeaderName
value
impl Into<String>
&self
name
impl IntoHeaderName
value
impl Into<String>
examples
```no_run
use async_graphql::*;
use ::http::header::ACCESS_CONTROL_ALLOW_ORIGIN.

struct Query.
` ` ` no_run use async_graphql :: * ; use :: http :: header :: ACCESS_CONTROL_ALLOW_ORIGIN . struct Query .
[object]
impl Query {
async fn greet(&self, ctx: &Context<'_>) -> String {

Headers can be inserted using the `http` constants
let was_in_headers = ctx.insert_http_header(ACCESS_CONTROL_ALLOW_ORIGIN, "*");
assert_eq!(was_in_headers, None).

They can also be inserted using &str
let was_in_headers = ctx.insert_http_header("Custom-Header", "1234");
assert_eq!(was_in_headers, None).

If multiple headers with the same key are `inserted` then the most recent
one overwrites the previous. If you want multiple headers for the same key, use
`append_http_header` for subsequent headers
let was_in_headers = ctx.insert_http_header("Custom-Header", "Hello World");
assert_eq!(was_in_headers, Some("1234".to_string())).


impl Query { async fn greet ( &self ctx : &Context< ' _ > ) - > String { Headers can be inserted using the ` http ` constants let was_in_headers = ctx . insert_http_header ( ACCESS_CONTROL_ALLOW_ORIGIN " * " ) ; assert_eq! ( was_in_headers None ) . They can also be inserted using &str let was_in_headers = ctx . insert_http_header ( " Custom - Header " " 1234 " ) ; assert_eq! ( was_in_headers None ) . If multiple headers with the same key are ` inserted ` then the most recent one overwrites the previous . If you want multiple headers for the same key use ` append_http_header ` for subsequent headers let was_in_headers = ctx . insert_http_header ( " Custom - Header " " Hello World " ) ; assert_eq! ( was_in_headers Some ( " 1234 " . to_string () )) .