jinxapi_github/v1_1_4/request/
apps_get_by_slug.rs

1//! Get an app
2//! 
3//! **Note**: The `:app_slug` is just the URL-friendly name of your GitHub App. You can find this on the settings page for your GitHub App (e.g., `https://github.com/settings/apps/:app_slug`).
4//! 
5//! If the GitHub App you specify is public, you can access this endpoint without authenticating. If the GitHub App you specify is private, you must authenticate with a [personal access token](https://docs.github.com/articles/creating-a-personal-access-token-for-the-command-line/) or an [installation access token](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-an-installation) to access this endpoint.
6//! 
7//! [API method documentation](https://docs.github.com/rest/reference/apps/#get-an-app)
8
9
10fn url_string(
11    base_url: &str,
12    p_app_slug: &str,
13) -> Result<String, crate::v1_1_4::ApiError> {
14    let trimmed = if base_url.is_empty() {
15        "https://api.github.com"
16    } else {
17        base_url.trim_end_matches('/')
18    };
19    let mut url = String::with_capacity(trimmed.len() + 23);
20    url.push_str(trimmed);
21    url.push_str("/apps/");
22    ::querylizer::Simple::extend(&mut url, &p_app_slug, false, &::querylizer::encode_path)?;
23    Ok(url)
24}
25
26#[cfg(feature = "hyper")]
27pub fn http_builder(
28    base_url: &str,
29    p_app_slug: &str,
30    h_user_agent: &str,
31    h_accept: ::std::option::Option<&str>,
32) -> Result<::http::request::Builder, crate::v1_1_4::ApiError> {
33    let url = url_string(
34        base_url,
35        p_app_slug,
36    )?;
37    let mut builder = ::http::request::Request::get(url);
38    builder = builder.header(
39        "User-Agent",
40        &::querylizer::Simple::to_string(&h_user_agent, false, &::querylizer::passthrough)?
41    );
42    if let Some(value) = &h_accept {
43        builder = builder.header(
44            "Accept",
45            &::querylizer::Simple::to_string(value, false, &::querylizer::passthrough)?
46        );
47    }
48    Ok(builder)
49}
50
51#[cfg(feature = "hyper")]
52#[inline]
53pub fn hyper_request(
54    builder: ::http::request::Builder,
55) -> Result<::http::request::Request<::hyper::Body>, crate::v1_1_4::ApiError> {
56    Ok(builder.body(::hyper::Body::empty())?)
57}
58
59#[cfg(feature = "reqwest")]
60pub fn reqwest_builder(
61    base_url: &str,
62    p_app_slug: &str,
63    h_user_agent: &str,
64    h_accept: ::std::option::Option<&str>,
65) -> Result<::reqwest::Request, crate::v1_1_4::ApiError> {
66    let url = url_string(
67        base_url,
68        p_app_slug,
69    )?;
70    let reqwest_url = ::reqwest::Url::parse(&url)?;
71    let mut request = ::reqwest::Request::new(::reqwest::Method::GET, reqwest_url);
72    let headers = request.headers_mut();
73    headers.append(
74        "User-Agent",
75        ::querylizer::Simple::to_string(&h_user_agent, false, &::querylizer::passthrough)?.try_into()?
76    );
77    if let Some(value) = &h_accept {
78        headers.append(
79            "Accept",
80            ::querylizer::Simple::to_string(value, false, &::querylizer::passthrough)?.try_into()?
81        );
82    }
83    Ok(request)
84}
85
86#[cfg(feature = "reqwest")]
87#[inline(always)]
88pub fn reqwest_request(
89    builder: ::reqwest::Request,
90) -> Result<::reqwest::Request, crate::v1_1_4::ApiError>
91{
92    Ok(builder)
93}
94
95#[cfg(feature = "reqwest-blocking")]
96pub fn reqwest_blocking_builder(
97    base_url: &str,
98    p_app_slug: &str,
99    h_user_agent: &str,
100    h_accept: ::std::option::Option<&str>,
101) -> Result<::reqwest::blocking::Request, crate::v1_1_4::ApiError> {
102    let url = url_string(
103        base_url,
104        p_app_slug,
105    )?;
106    let reqwest_url = ::reqwest::Url::parse(&url)?;
107    let mut request = ::reqwest::blocking::Request::new(::reqwest::Method::GET, reqwest_url);
108    let headers = request.headers_mut();
109    headers.append(
110        "User-Agent",
111        ::querylizer::Simple::to_string(&h_user_agent, false, &::querylizer::passthrough)?.try_into()?
112    );
113    if let Some(value) = &h_accept {
114        headers.append(
115            "Accept",
116            ::querylizer::Simple::to_string(value, false, &::querylizer::passthrough)?.try_into()?
117        );
118    }
119    Ok(request)
120}
121
122#[cfg(feature = "reqwest-blocking")]
123#[inline(always)]
124pub fn reqwest_blocking_request(
125    builder: ::reqwest::blocking::Request,
126) -> Result<::reqwest::blocking::Request, crate::v1_1_4::ApiError>
127{
128    Ok(builder)
129}