From 0db54c044623cb677fc1d30c2a0d73dba3f23c29 Mon Sep 17 00:00:00 2001 From: Madeorsk Date: Sun, 24 Feb 2019 14:36:44 +0100 Subject: [PATCH] Allow HEAD method for polls endpoints. --- webroot/index.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/webroot/index.php b/webroot/index.php index 55d1ebe..1f57a87 100644 --- a/webroot/index.php +++ b/webroot/index.php @@ -22,7 +22,7 @@ Flight::route("POST /polls", function () { Flight::halt(403, "

403 Forbidden

Invalid Content-Type.

"); }); -Flight::route("GET /polls/@id:[a-fA-F0-9]+", function ($id) { +Flight::route("HEAD|GET /polls/@id:[a-fA-F0-9]+", function ($id) { global $VERLAINE; $poll = Poll::load_poll($id); if ($poll) @@ -95,7 +95,7 @@ Flight::route("POST /polls/@id:[a-fA-F0-9]+/vote", function ($id) { Flight::notFound(); }); -Flight::route("GET /polls/@id:[a-fA-F0-9]+/results", function ($id) { +Flight::route("HEAD|GET /polls/@id:[a-fA-F0-9]+/results", function ($id) { global $VERLAINE; $poll = Poll::load_poll($id); if ($poll) @@ -138,13 +138,11 @@ Flight::route("GET|DELETE /polls/@id:[a-fA-F0-9]+/@token:[a-fA-F0-9]+", function Flight::notFound(); }); -Flight::route("GET /polls/@id:[a-fA-F0-9]+/results/svg", function ($id) { +Flight::route("HEAD|GET /polls/@id:[a-fA-F0-9]+/results/svg", function ($id) { global $VERLAINE; $poll = Poll::load_poll($id); if ($poll) - { Flight::render("svg/results", ["poll" => $poll, "colors" => $VERLAINE["chart_colors"]]); - } else Flight::notFound(); });