sal/rfs-client/openapi/src/apis/website_serving_api.rs
2025-06-24 16:10:39 +03:00

54 lines
1.8 KiB
Rust

/*
* rfs
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.2.0
*
* Generated by: https://openapi-generator.tech
*/
use reqwest;
use serde::{Deserialize, Serialize, de::Error as _};
use crate::{apis::ResponseContent, models};
use super::{Error, configuration, ContentType};
/// struct for typed errors of method [`serve_website_handler`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ServeWebsiteHandlerError {
Status404(models::ResponseError),
Status500(models::ResponseError),
UnknownValue(serde_json::Value),
}
pub async fn serve_website_handler(configuration: &configuration::Configuration, website_hash: &str, path: &str) -> Result<reqwest::Response, Error<ServeWebsiteHandlerError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_website_hash = website_hash;
let p_path = path;
let uri_str = format!("{}/api/v1/website/{website_hash}/{path}", configuration.base_path, website_hash=crate::apis::urlencode(p_website_hash), path=crate::apis::urlencode(p_path));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(resp)
} else {
let content = resp.text().await?;
let entity: Option<ServeWebsiteHandlerError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}