aboutsummaryrefslogtreecommitdiff
path: root/lib/Server/Util.hs
diff options
context:
space:
mode:
authorstuebinm2022-07-17 03:05:16 +0200
committerstuebinm2022-07-17 03:05:16 +0200
commit04f3304e7f8db44a21e4f9da0d481facddc41a26 (patch)
tree64063d6853324a56eb87098bc865e99732226346 /lib/Server/Util.hs
parenta763733e3b2d0679e2432fdcb29d2348fe790370 (diff)
some work on the control room
(it can do useful stuff! but it also still breaks on some things!)
Diffstat (limited to 'lib/Server/Util.hs')
-rw-r--r--lib/Server/Util.hs11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/Server/Util.hs b/lib/Server/Util.hs
index 45c2477..1c62663 100644
--- a/lib/Server/Util.hs
+++ b/lib/Server/Util.hs
@@ -1,13 +1,18 @@
-
+{-# LANGUAGE FlexibleContexts #-}
-- | mostly the monad the service runs in
-module Server.Util (Service, ServiceM, runService) where
+module Server.Util (Service, ServiceM, runService, redirect) where
import Control.Monad.Logger (LoggingT, runStderrLoggingT)
-import Servant (Handler, ServerT)
+import Data.ByteString (ByteString)
+import Servant (Handler, ServerError, ServerT, err302,
+ errHeaders, throwError)
type ServiceM = LoggingT Handler
type Service api = ServerT api ServiceM
runService :: ServiceM a -> Handler a
runService = runStderrLoggingT
+
+redirect :: ByteString -> ServiceM a
+redirect path = throwError $ err302 { errHeaders = [("Location", path)] }