aboutsummaryrefslogtreecommitdiff
path: root/src/response.rs
diff options
context:
space:
mode:
authorFuwn <[email protected]>2022-07-03 05:03:00 +0000
committerFuwn <[email protected]>2022-07-03 05:03:00 +0000
commit9db0750df8b0eed28851cca4b880da2b8ee50bc7 (patch)
treef1e4105c7ade0f4461becafe0fa82f7b03e6298b /src/response.rs
parentfeat(response): url error handling (diff)
downloadseptember-9db0750df8b0eed28851cca4b880da2b8ee50bc7.tar.xz
september-9db0750df8b0eed28851cca4b880da2b8ee50bc7.zip
feat(response): add nocss route
Diffstat (limited to 'src/response.rs')
-rw-r--r--src/response.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/response.rs b/src/response.rs
index 486ea3e..288a07f 100644
--- a/src/response.rs
+++ b/src/response.rs
@@ -28,6 +28,7 @@ pub async fn default(
) -> Result<HttpResponse, Error> {
let mut is_proxy = false;
let mut is_raw = false;
+ let mut is_nocss = false;
// Try to construct a Gemini URL
let url = match make_url(
&format!("{}{}", req.path(), {
@@ -41,6 +42,7 @@ pub async fn default(
false,
&mut is_proxy,
&mut is_raw,
+ &mut is_nocss,
) {
Ok(url) => url,
Err(e) => {
@@ -65,6 +67,7 @@ pub async fn default(
true,
&mut is_proxy,
&mut is_raw,
+ &mut is_nocss,
) {
Ok(url) => url,
Err(e) => {
@@ -123,6 +126,16 @@ pub async fn default(
);
}
+ if is_nocss {
+ html_context.push_str(&gemini_html.1);
+
+ return Ok(
+ HttpResponse::Ok()
+ .content_type(format!("text/html; charset={}", meta.mime()))
+ .body(html_context),
+ );
+ }
+
// Try to add an external stylesheet from the `CSS_EXTERNAL` environment
// variable.
if let Ok(css) = var("CSS_EXTERNAL") {