about summary refs log tree commit diff stats
path: root/pkgs/by-name/ba/back/src/web/responses.rs
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-06-06 22:08:26 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-06-06 22:08:26 +0200
commit21b9a461dafeab63893d82a82d7b84ffe3a59c40 (patch)
treedfb8e657e2f36b426d9fba1b1a703431836d92e5 /pkgs/by-name/ba/back/src/web/responses.rs
parentflake.nix: Use the packaged version of `ragenix` (diff)
downloadnixos-server-21b9a461dafeab63893d82a82d7b84ffe3a59c40.zip
pkgs/back: Remove
Back has been moved out-of-tree.
Diffstat (limited to 'pkgs/by-name/ba/back/src/web/responses.rs')
-rw-r--r--pkgs/by-name/ba/back/src/web/responses.rs50
1 files changed, 0 insertions, 50 deletions
diff --git a/pkgs/by-name/ba/back/src/web/responses.rs b/pkgs/by-name/ba/back/src/web/responses.rs
deleted file mode 100644
index e50f8c2..0000000
--- a/pkgs/by-name/ba/back/src/web/responses.rs
+++ /dev/null
@@ -1,50 +0,0 @@
-use std::convert::Infallible;
-
-use bytes::Bytes;
-use http::{Response, StatusCode, Version};
-use http_body_util::{combinators::BoxBody, BodyExt, Full};
-
-use crate::{error, git_bug::format::HtmlString};
-
-pub(super) fn html_response<T: Into<Bytes>>(html_text: T) -> Response<BoxBody<Bytes, Infallible>> {
-    html_response_status(html_text, StatusCode::OK)
-}
-
-pub(super) fn html_response_status<T: Into<Bytes>>(
-    html_text: T,
-    status: StatusCode,
-) -> Response<BoxBody<Bytes, Infallible>> {
-    html_response_status_content_type(html_text, status, "text/html")
-}
-
-pub(super) fn html_response_status_content_type<T: Into<Bytes>>(
-    html_text: T,
-    status: StatusCode,
-    content_type: &str,
-) -> Response<BoxBody<Bytes, Infallible>> {
-    Response::builder()
-        .status(status)
-        .version(Version::HTTP_2)
-        .header("Content-Type", format!("{}; charset=utf-8", content_type))
-        .header("x-content-type-options", "nosniff")
-        .header("x-frame-options", "SAMEORIGIN")
-        .body(full(html_text))
-        .expect("This will always build")
-}
-
-fn full<T: Into<Bytes>>(chunk: T) -> BoxBody<Bytes, Infallible> {
-    Full::new(chunk.into()).boxed()
-}
-
-// FIXME: Not all errors should return `INTERNAL_SERVER_ERROR`. <2025-03-08>
-impl error::Error {
-    pub fn into_response(self) -> Response<BoxBody<Bytes, Infallible>> {
-        html_response_status(
-            format!(
-                "<h1> Internal server error. </h1> <pre>Error: {}</pre>",
-                HtmlString::from(self.to_string())
-            ),
-            StatusCode::INTERNAL_SERVER_ERROR,
-        )
-    }
-}