aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2018-11-13 22:10:13 +0100
committerTeddy Wing2018-11-13 22:10:13 +0100
commitd55de8c8cd746a7d5c537c3b2ca49994d3007b66 (patch)
treef3e223103684a088d1e288cbced8677337542ea2
parenta1184f48a0a4930f3e378860ba212051516b8717 (diff)
downloaddome-key-web-d55de8c8cd746a7d5c537c3b2ca49994d3007b66.tar.bz2
Add 400 error page
HTML copied from the 404 page, but I remove the `text-center` on the error message because it doesn't look good. Took a multiline message for me to realise it.
-rw-r--r--400.html34
-rw-r--r--license-generator/src/bin/license.rs5
-rw-r--r--license-generator/src/response.rs4
3 files changed, 43 insertions, 0 deletions
diff --git a/400.html b/400.html
new file mode 100644
index 0000000..6f4de30
--- /dev/null
+++ b/400.html
@@ -0,0 +1,34 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <title>400 – DomeKey</title>
+ <meta name="description" content="DomeKey gives you the power to remap your headphone buttons to any action you can think of. Define mappings in text using a Vim-like configuration language." />
+
+ <meta name="viewport" content="width=device-width">
+
+ <link rel="stylesheet" href="assets/styles.css" />
+</head>
+<body>
+ <div class="content">
+ <header>
+ <h1>DomeKey</h1>
+ <img src="assets/logo.svg" alt="DomeKey logo" />
+ </header>
+
+ <p class="font-size-1.52 color-maroon">
+ Control your computer with a pair of headphones
+ </p>
+
+ <p class="font-size-15 text-center margin-top-0.5 margin-bottom-0.63">
+ 400
+ </p>
+
+ <p>
+ The query parameters are incorrect. If you were sent a link to this page,
+ try copying and pasting it in its entirety (including all query string
+ parameters) into your browser’s location bar.
+ </p>
+ </div>
+</body>
+</html>
diff --git a/license-generator/src/bin/license.rs b/license-generator/src/bin/license.rs
index 8c77670..f35407b 100644
--- a/license-generator/src/bin/license.rs
+++ b/license-generator/src/bin/license.rs
@@ -55,6 +55,11 @@ where W: 'a + Write {
}
fn error_400(&mut self) {
+ let page_400 = include_str!("../../../400.html");
+ response::set_400(self.writer)
+ .and_then(|_|
+ Ok(write!(self.writer, "Content-Type: text/html\n\n{}", page_400)?)
+ ).unwrap_or(())
}
fn error_404(&mut self) {
diff --git a/license-generator/src/response.rs b/license-generator/src/response.rs
index cf91e4e..6809988 100644
--- a/license-generator/src/response.rs
+++ b/license-generator/src/response.rs
@@ -2,6 +2,10 @@ use std::io::Write;
use errors::*;
+pub fn set_400<W: Write>(w: &mut W) -> Result<()> {
+ Ok(writeln!(w, "Status: 400")?)
+}
+
pub fn set_403<W: Write>(w: &mut W) -> Result<()> {
Ok(writeln!(w, "Status: 403")?)
}