♻️ refactor: standardize the content-type header by using an enum value over typing it manually (#474)

* ♻️  refactor: change content-type

* 🐛  fix: change parameters that were passed to the settings function

---------

Co-authored-by: neon_arch <mustafadhuleb53@gmail.com>
This commit is contained in:
Леонтий Вартанян 2023-12-31 13:31:07 +03:00 committed by GitHub
parent 5b4864424a
commit 5020f36c90
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 47 additions and 57 deletions

View file

@ -11,7 +11,7 @@ use crate::{
},
results::aggregator::aggregate,
};
use actix_web::{get, web, HttpRequest, HttpResponse};
use actix_web::{get, http::header::ContentType, web, HttpRequest, HttpResponse};
use regex::Regex;
use std::{
fs::File,
@ -68,18 +68,16 @@ pub async fn search(
get_results(page + 1)
);
Ok(HttpResponse::Ok()
.content_type("text/html; charset=utf-8")
.body(
crate::templates::views::search::search(
&config.style.colorscheme,
&config.style.theme,
&config.style.animation,
query,
&results?,
)
.0,
))
Ok(HttpResponse::Ok().content_type(ContentType::html()).body(
crate::templates::views::search::search(
&config.style.colorscheme,
&config.style.theme,
&config.style.animation,
query,
&results?,
)
.0,
))
}
None => Ok(HttpResponse::TemporaryRedirect()
.insert_header(("location", "/"))