aboutsummaryrefslogtreecommitdiffstats
path: root/license-generator/src/response.rs
diff options
context:
space:
mode:
authorTeddy Wing2018-11-10 23:49:20 +0100
committerTeddy Wing2018-11-10 23:49:20 +0100
commit86e5b666e5fea3e037734f8aacb0537a365518ab (patch)
treecac20aadfaa38919c37f76af9aa7d6d6352b2cbd /license-generator/src/response.rs
parent20f7a268cce05cd63842adbc7a5d05d4d4cc5bc7 (diff)
downloaddome-key-web-86e5b666e5fea3e037734f8aacb0537a365518ab.tar.bz2
main(): Set up HTTP responses
* If no `REQUEST_METHOD` is found, send a 500 error * If the `REQUEST_METHOD` is not "POST", send a 405 * If POST params could not be read from stdin, send 500 * If an error occurred during request verification, send 500 * If the request didn't pass verification, send 403 * Otherwise send 200
Diffstat (limited to 'license-generator/src/response.rs')
-rw-r--r--license-generator/src/response.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/license-generator/src/response.rs b/license-generator/src/response.rs
new file mode 100644
index 0000000..701bf1a
--- /dev/null
+++ b/license-generator/src/response.rs
@@ -0,0 +1,21 @@
+use std::io::Write;
+
+use errors::*;
+
+pub fn set_403<W: Write>(w: &mut W) -> Result<()> {
+ Ok(writeln!(w, "Status: 403")?)
+}
+
+pub fn set_405<W: Write>(w: &mut W, allowed_methods: &str) -> Result<()> {
+ Ok(
+ writeln!(
+ w,
+ "Status: 405
+Allow: {}",
+ allowed_methods)?
+ )
+}
+
+pub fn set_500<W: Write>(w: &mut W) -> Result<()> {
+ Ok(writeln!(w, "Status: 500")?)
+}