Struct rss_autogen_giscus::HttpClients
source · pub struct HttpClients {
pub html: Client,
pub gql: Client,
pub website_rss_url: String,
pub github_rest_url: String,
pub github_gql_url: String,
pub repo_owner: String,
pub repo_name: String,
pub discussion_category: String,
pub lookback_days: i64,
}Expand description
Monostruct containing the HTML and GraphQL clients used to create the discussion, along with the necessary URLs.
Fields§
§html: ClientHTML client for accessing the RSS feed, blog post, and GitHub REST API.
gql: ClientGraphQL client for accessing the GitHub GraphQL API. This client must be created with the
following headers, using ClientBuilder::default_headers:
Accept: application/vnd.github+jsonAuthorization: <GitHub token>User-Agent: <appropriate user agent name>X-Github-Next-Global-ID: 1
website_rss_url: StringURL for the blog’s RSS feed.
github_rest_url: StringURL for GitHub REST API, typically https://api.github.com
github_gql_url: StringURL for GitHub GraphQL API, typically https://api.github.com/graphql
repo_owner: StringOwner of the repository hosting the comments.
repo_name: StringName of the repository hosting the comments
discussion_category: StringName of the discussion category that the comments should be posted under.
lookback_days: i64The number of days to look back in history, to check if a previous discussion occurred. Limit is disabled if set to 0.
Implementations§
source§impl HttpClients
impl HttpClients
sourcepub fn init() -> Arc<Self>
pub fn init() -> Arc<Self>
Create the reqwest clients, and pull the other values from environment variables. These are
assumed to be formatted like the
default values available in GitHub Actions,
except for DISCUSSION_CATEGORY and LOOKBACK_DAYS:
GITHUB_TOKEN, used in the authorization header for the GraphQL clientWEBSITE_RSS_URL, requiredGITHUB_API_URL, optional (defaults to https://api.github.com)GITHUB_GRAPHQL_URL, optional (defaults to https://api.github.com/graphql)GITHUB_REPOSITORY_OWNER, requiredGITHUB_REPOSITORYin format<owner>/<repo>, required (mapped torepo_name)DISCUSSION_CATEGORYas the name of the category to post under, requiredLOOKBACK_DAYS, optional (defaults to 7)
use std::env;
use rss_autogen_giscus::HttpClients;
env::set_var("WEBSITE_RSS_URL", "https://rss.cbc.ca/lineup/topstories.xml");
env::set_var("GITHUB_TOKEN", "secret_github_pat");
env::set_var("GITHUB_REPOSITORY_OWNER", "microsoft");
env::set_var("GITHUB_REPOSITORY", "microsoft/vscode");
env::set_var("DISCUSSION_CATEGORY", "CBC News");
env::set_var("LOOKBACK_DAYS", "0");
let clients = HttpClients::init();Trait Implementations§
source§impl Clone for HttpClients
impl Clone for HttpClients
source§fn clone(&self) -> HttpClients
fn clone(&self) -> HttpClients
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more