about summary refs log tree commit diff
path: root/src/frontend/templates/mod.rs
diff options
context:
space:
mode:
authorVika <vika@fireburn.ru>2022-03-02 23:41:58 +0300
committerVika <vika@fireburn.ru>2022-03-02 23:41:58 +0300
commit4de2f901a549f051c1a03b83fc114d38638dcbfb (patch)
tree9b18a2e9f52367ecf5c606df6e4ff1d475f935c1 /src/frontend/templates/mod.rs
parentf837312f3a162daa865600c5248589935d2aac57 (diff)
frontend: convert to warp
Warp is using hyperium/http instead of http-types, so I replaced all
of the http-types usage (mostly status codes) by Warp's
http::StatusCode.

Additionally some of the struct fields were made public to allow
initialization from public code.
Diffstat (limited to 'src/frontend/templates/mod.rs')
-rw-r--r--src/frontend/templates/mod.rs38
1 files changed, 20 insertions, 18 deletions
diff --git a/src/frontend/templates/mod.rs b/src/frontend/templates/mod.rs
index c21d30b..364a716 100644
--- a/src/frontend/templates/mod.rs
+++ b/src/frontend/templates/mod.rs
@@ -1,7 +1,7 @@
 use crate::database::MicropubChannel;
 use crate::frontend::IndiewebEndpoints;
 use ellipse::Ellipse;
-use http_types::StatusCode;
+use warp::http::StatusCode;
 use log::error;
 
 /// Return a pretty location specifier from a geo: URI.
@@ -397,12 +397,12 @@ markup::define! {
         @Feed { feed }
     }
     ErrorPage(code: StatusCode, msg: Option<String>) {
-        h1 { @format!("HTTP {} {}", code, code.canonical_reason()) }
-        @match code {
-            StatusCode::Unauthorized => {
+        h1 { @format!("HTTP {}", code) }
+        @match *code {
+            StatusCode::UNAUTHORIZED => {
                 p { "Looks like you need to authenticate yourself before seeing this page. Try logging in with IndieAuth using the Login button above!" }
             }
-            StatusCode::Forbidden => {
+            StatusCode::FORBIDDEN => {
                 p { "Looks like you're forbidden from viewing this page." }
                 p {
                     "This might've been caused by being banned from viewing my website"
@@ -410,16 +410,16 @@ markup::define! {
                     "like a private post that's not intended for you. It's ok, it happens."
                 }
             }
-            StatusCode::Gone => {
+            StatusCode::GONE => {
                 p { "Looks like the page you're trying to find is gone and is never coming back." }
             }
-            StatusCode::UnavailableForLegalReasons => {
+            StatusCode::UNAVAILABLE_FOR_LEGAL_REASONS => {
             p { "The page is there, but I can't legally provide it to you because the censorship said so." }
             }
-            StatusCode::NotFound => {
+            StatusCode::NOT_FOUND => {
                 p { "Looks like there's no such page. Maybe you or someone else mistyped a URL or my database experienced data loss." }
             }
-            StatusCode::ImATeapot => {
+            StatusCode::IM_A_TEAPOT => {
                 p { "Wait, do you seriously expect my website to brew you coffee? It's not a coffee machine!" }
 
                 p {
@@ -433,16 +433,18 @@ markup::define! {
                     }
                 }
             }
-            StatusCode::BadRequest => {
-                @if msg.is_none() {
-                    p {
-                        "There was an undescribed error in your request. "
-                        "Please try again later or with a different request."
+            StatusCode::BAD_REQUEST => {
+                @match msg {
+                    None => {
+                        p {
+                            "There was an undescribed error in your request. "
+                            "Please try again later or with a different request."
+                        }
                     }
-                } else {
-                    p {
-                        "There was a following error in your request: "
-                        @msg.as_ref().unwrap()
+                    Some(msg) => {
+                        p {
+                            "There was a following error in your request: " @msg
+                        }
                     }
                 }
             }