From 751b725332fd0e9397b7cfd3f3a3bff14056c232 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Tue, 7 Apr 2020 22:07:07 -0700 Subject: Return the app state as a simple dashboard --- Run/Que/Server.hs | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'Run/Que') diff --git a/Run/Que/Server.hs b/Run/Que/Server.hs index 4974498..146a16a 100644 --- a/Run/Que/Server.hs +++ b/Run/Que/Server.hs @@ -35,6 +35,7 @@ import qualified Data.Text.Encoding as Encoding import Data.Text.Lazy ( Text , fromStrict ) +import qualified Data.Text.Lazy.IO as Text import qualified Network.HTTP.Types.Status as Http import qualified Network.Wai as Wai import qualified Network.Wai.Handler.Warp as Warp @@ -84,6 +85,19 @@ routes = do Scotty.get (Scotty.literal "/index.html") <| Scotty.redirect "/_/index" Scotty.get (Scotty.literal "/") <| Scotty.redirect "/_/index" + -- | GET /_/dash + Scotty.get (Scotty.literal "/_/dash") <| do + authkey <- fromMaybe "" Scotty.status Http.ok200 - (_, Just "73.222.221.62", _) -> Scotty.status Http.ok200 - (_, _, Just ("localhost:3000")) -> Scotty.status Http.ok200 - _ -> Scotty.status Http.methodNotAllowed405 - >> Scotty.text "not allowed: _ is a reserved namespace" + when ("_" == ns && authkey /= adminkey) + <| Scotty.status Http.methodNotAllowed405 + >> Scotty.text "not allowed: _ is a reserved namespace" guardNs ns ["pub", "_"] -- passed all auth checks app . modify <| upsertNamespace ns -- cgit v1.2.3