parent
439467f730
commit
cd140f0160
4 changed files with 15 additions and 15 deletions
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue