refactor
Some checks failed
ci/woodpecker/push/test Pipeline failed

This commit is contained in:
JMARyA 2024-12-29 21:35:48 +01:00
parent 439467f730
commit cd140f0160
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
4 changed files with 15 additions and 15 deletions

View file

@ -15,10 +15,10 @@ pub struct DataResponse {
impl DataResponse {
#[must_use]
pub fn new(data: Vec<u8>, content_type: &str, cache_duration: Option<u64>) -> Self {
pub fn new(data: Vec<u8>, content_type: String, cache_duration: Option<u64>) -> Self {
Self {
data,
content_type: content_type.to_string(),
content_type,
cache_duration,
}
}

View file

@ -67,8 +67,8 @@ pub fn respond_json(json: &serde_json::Value) -> StringResponse {
/// # Returns
/// A `StringResponse` with status `200 OK`, content type `text/html`, and the HTML content as the body.
#[must_use]
pub fn respond_html(html: &str) -> StringResponse {
(Status::Ok, (ContentType::HTML, html.to_string()))
pub fn respond_html(html: String) -> StringResponse {
(Status::Ok, (ContentType::HTML, html))
}
/// Helper function to create an JS HTTP response.
@ -79,8 +79,8 @@ pub fn respond_html(html: &str) -> StringResponse {
/// # Returns
/// A `StringResponse` with status `200 OK`, content type `text/javascript`, and the JS content as the body.
#[must_use]
pub fn respond_script(script: &str) -> StringResponse {
(Status::Ok, (ContentType::JavaScript, script.to_string()))
pub fn respond_script(script: String) -> StringResponse {
(Status::Ok, (ContentType::JavaScript, script))
}
/// Creates a custom HTTP response with the specified status, content type, and body.