freya-components 0.5.0-rc.4

Components for Freya apps
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use freya_core::prelude::*;
use reqwest::blocking::Client;

/// Shared blocking HTTP client used to fetch remote assets.
pub(crate) struct Http;

impl Http {
    /// Returns the shared [`Client`], lazily creating it in the global contexts on first use.
    pub(crate) fn get() -> Client {
        GlobalContexts::get().get_context_or_insert(|| {
            Client::builder()
                .build()
                .expect("Failed to build the HTTP client.")
        })
    }
}