Spaces:
Running
Running
maokwen
commited on
π fix: explicit Content-Type header for HTTP response (#457)
Browse files- src/server/router.rs +34 -28
src/server/router.rs
CHANGED
@@ -12,14 +12,16 @@ use std::fs::read_to_string;
|
|
12 |
/// Handles the route of index page or main page of the `websurfx` meta search engine website.
|
13 |
#[get("/")]
|
14 |
pub async fn index(config: web::Data<Config>) -> Result<HttpResponse, Box<dyn std::error::Error>> {
|
15 |
-
Ok(HttpResponse::Ok()
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
|
|
23 |
}
|
24 |
|
25 |
/// Handles the route of any other accessed route/page which is not provided by the
|
@@ -52,14 +54,16 @@ pub async fn robots_data(_req: HttpRequest) -> Result<HttpResponse, Box<dyn std:
|
|
52 |
/// Handles the route of about page of the `websurfx` meta search engine website.
|
53 |
#[get("/about")]
|
54 |
pub async fn about(config: web::Data<Config>) -> Result<HttpResponse, Box<dyn std::error::Error>> {
|
55 |
-
Ok(HttpResponse::Ok()
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
|
|
|
|
63 |
}
|
64 |
|
65 |
/// Handles the route of settings page of the `websurfx` meta search engine website.
|
@@ -67,16 +71,18 @@ pub async fn about(config: web::Data<Config>) -> Result<HttpResponse, Box<dyn st
|
|
67 |
pub async fn settings(
|
68 |
config: web::Data<Config>,
|
69 |
) -> Result<HttpResponse, Box<dyn std::error::Error>> {
|
70 |
-
Ok(HttpResponse::Ok()
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
.
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
|
|
|
|
82 |
}
|
|
|
12 |
/// Handles the route of index page or main page of the `websurfx` meta search engine website.
|
13 |
#[get("/")]
|
14 |
pub async fn index(config: web::Data<Config>) -> Result<HttpResponse, Box<dyn std::error::Error>> {
|
15 |
+
Ok(HttpResponse::Ok()
|
16 |
+
.content_type("text/html; charset=utf-8")
|
17 |
+
.body(
|
18 |
+
crate::templates::views::index::index(
|
19 |
+
&config.style.colorscheme,
|
20 |
+
&config.style.theme,
|
21 |
+
&config.style.animation,
|
22 |
+
)
|
23 |
+
.0,
|
24 |
+
))
|
25 |
}
|
26 |
|
27 |
/// Handles the route of any other accessed route/page which is not provided by the
|
|
|
54 |
/// Handles the route of about page of the `websurfx` meta search engine website.
|
55 |
#[get("/about")]
|
56 |
pub async fn about(config: web::Data<Config>) -> Result<HttpResponse, Box<dyn std::error::Error>> {
|
57 |
+
Ok(HttpResponse::Ok()
|
58 |
+
.content_type("text/html; charset=utf-8")
|
59 |
+
.body(
|
60 |
+
crate::templates::views::about::about(
|
61 |
+
&config.style.colorscheme,
|
62 |
+
&config.style.theme,
|
63 |
+
&config.style.animation,
|
64 |
+
)
|
65 |
+
.0,
|
66 |
+
))
|
67 |
}
|
68 |
|
69 |
/// Handles the route of settings page of the `websurfx` meta search engine website.
|
|
|
71 |
pub async fn settings(
|
72 |
config: web::Data<Config>,
|
73 |
) -> Result<HttpResponse, Box<dyn std::error::Error>> {
|
74 |
+
Ok(HttpResponse::Ok()
|
75 |
+
.content_type("text/html; charset=utf-8")
|
76 |
+
.body(
|
77 |
+
crate::templates::views::settings::settings(
|
78 |
+
&config.style.colorscheme,
|
79 |
+
&config.style.theme,
|
80 |
+
&config.style.animation,
|
81 |
+
&config
|
82 |
+
.upstream_search_engines
|
83 |
+
.keys()
|
84 |
+
.collect::<Vec<&String>>(),
|
85 |
+
)?
|
86 |
+
.0,
|
87 |
+
))
|
88 |
}
|